菊池 Blog

移転しました 続・菊池 和彦の足跡

AILight Banner
AILight Blog

プロフィール

菊池 Blog

目次

Blog 利用状況

記事分類

過去の記事

タグ

MSBuild.Community.Tasks のパッチ

ベースリビジョンは 255 です。

SvnInfo のいじりが中心かな。

svn info の出力を直接評価してたが、これだと日本語だと通らない(英語環境だけでしか通らない)ので svn info --xml でのXML出力を評価する様にしてみました。

SvnVersion は svnversion.exe を x64 環境下だと見つけられないので SvnClient からかっぱらってきた svn.exe の探し方を元に svnversion.exe を見つけるようにしました。(同じディレクトリにおいてない人は居ないでしょうって事で)

InstallAspNet11 は .NET Framework フォルダはあるけど、インストールされていないケースがあるみたいで、Ignore に落とすルールの追加です。

XmlUpdateTestはファイルの位置がちがわね?

 

誰かCommiter な人が見てたら当ててください。

現状、MSBuild.Community.Tasks.TestではXsltOneInputだけが通りません、テストで使う xsl がリポジトリに入ってないっぽいって事で無視してます。

patch ファイルでほしいかたは←の連絡するから要求して下さい。

 

Index: Source/MSBuild.Community.Tasks.Tests/AspNet/InstallAspNetTest.cs
===================================================================
--- Source/MSBuild.Community.Tasks.Tests/AspNet/InstallAspNetTest.cs (revision 255)
+++ Source/MSBuild.Community.Tasks.Tests/AspNet/InstallAspNetTest.cs (working copy)
@@ -1,5 +1,6 @@
 // $Id$
 using System;
+using Microsoft.Build.Utilities;
 using NUnit.Framework;
 using MSBuild.Community.Tasks.AspNet;
 
@@ -129,6 +130,10 @@
         [Test]
         public void InstallAspNet11()
         {
+            if (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version11)==null )
+            {
+                Assert.Ignore(".NET Framework 1.1 is not installed.");
+            }
             if (!System.IO.Directory.Exists(Environment.ExpandEnvironmentVariables(@"%SystemRoot%\Microsoft.NET\Framework\v1.1.4322")))
             {
                 Assert.Ignore(".NET Framework 1.1 is not installed.");
Index: Source/MSBuild.Community.Tasks.Tests/Subversion/SvnInfoTest.cs
===================================================================
--- Source/MSBuild.Community.Tasks.Tests/Subversion/SvnInfoTest.cs (revision 255)
+++ Source/MSBuild.Community.Tasks.Tests/Subversion/SvnInfoTest.cs (working copy)
@@ -44,9 +44,28 @@
             // could also be svn://
             Assert.AreEqual(0, val.IndexOf("http://"));
             Assert.Greater(val.IndexOf("Source/MSBuild.Community.Tasks.Tests"), 0);
-            Assert.AreEqual(NodeKind.directory, info.NodeKind);
+            Assert.AreEqual(NodeKind.directory.ToString(), info.NodeKind);
             Assert.AreEqual("http://msbuildtasks.tigris.org/svn/msbuildtasks", info.RepositoryRoot);
-            Assert.AreNotEqual(Guid.Empty, info.RepositoryUuid);
+            Assert.AreNotEqual(Guid.Empty.ToString(), info.RepositoryUuid);
+            Assert.Greater( info.Revision,0 );
+            Assert.Greater( info.LastChangedRevision,0 );
+            Assert.IsFalse( string.IsNullOrEmpty(info.LastChangedAuthor) );
+            DateTime resultDateTime;
+            Assert.IsTrue(DateTime.TryParse(info.LastChangedDate, out resultDateTime));
+            Assert.AreNotEqual( info.Schedule.ToString() ,"unknown" );
         }
     }
 }
+
+/* updated kazuhiko kikuchi <kazuk.dll@gmail.com>     2006/09/15
+ *
+ *   Test Failed at
+ *      AreEqual( NodeKind.directory , info.NodeKind )
+ *       that was Enum Type and String , allways not equal.
+ *       modified string and string AerEqual Test
+ *      AreEqual( Guid.Empty , info.RepositoryUuid )
+ *       that was Guid Type and String , allways not equal.
+ *       modified string and string AreEqual Test
+ *   Add test for Revision, LastChangedRevieison, LastChangedDate,
+ *
+ */
\ No newline at end of file
Index: Source/MSBuild.Community.Tasks.Tests/XmlUpdateTest.cs
===================================================================
--- Source/MSBuild.Community.Tasks.Tests/XmlUpdateTest.cs (revision 255)
+++ Source/MSBuild.Community.Tasks.Tests/XmlUpdateTest.cs (working copy)
@@ -22,7 +22,7 @@
             task.Prefix = "n";
             task.Namespace = "http://schemas.microsoft.com/developer/msbuild/2003";
             string prjRootPath = TaskUtility.getProjectRootDirectory(true);
-            task.XmlFileName = Path.Combine(prjRootPath, @"Source\MSBuild.Community.Tasks\Subversion.proj");
+            task.XmlFileName = Path.Combine(prjRootPath, @"Source\Subversion.proj");
             task.XPath = "/n:Project/n:PropertyGroup/n:LastUpdate";
             task.Value = DateTime.Now.ToLongDateString();
            
Index: Source/MSBuild.Community.Tasks/Subversion/SvnInfo.cs
===================================================================
--- Source/MSBuild.Community.Tasks/Subversion/SvnInfo.cs (revision 255)
+++ Source/MSBuild.Community.Tasks/Subversion/SvnInfo.cs (working copy)
@@ -1,7 +1,9 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using System.Xml;
 using Microsoft.Build.Framework;
+using System.IO;
 
 // $Id: SvnCheckout.cs 102 2006-01-09 18:01:13Z iko $
 
@@ -72,7 +74,7 @@
         /// </summary>
         public SvnInfo()
         {
-            base.Command = "info";
+            Command = "info --xml";
             ResetMemberVariables();
         }
 
@@ -120,10 +122,55 @@
             {
                 ResetMemberVariables();
             }
-
+            string strXml = sbXml.ToString();
+            XmlDocument doc = new XmlDocument();
+            doc.Load( new StringReader(strXml));
+            XmlNode node = doc.SelectSingleNode("//info/entry/@kind");
+            if (node != null)
+            {
+                switch (node.Value)
+                {
+                    case "dir":
+                        m_eNodeKind = Subversion.NodeKind.directory;
+                        break;
+                    case "file":
+                        m_eNodeKind = Subversion.NodeKind.file;
+                        break;
+                    default:
+                        break;
+                }
+            }
+            node = doc.SelectSingleNode("//info/entry/url");
+            if (node != null) RepositoryPath = node.InnerText;
+            node = doc.SelectSingleNode("//info/entry/repository/root");
+            if (node != null) m_strRepositoryRoot = node.InnerText;
+            node = doc.SelectSingleNode("//info/entry/repository/uuid");
+            if (node != null) m_Guid = new Guid(node.InnerText);
+            node = doc.SelectSingleNode("//info/entry/@revision");
+            if (node != null) Revision = int.Parse( node.Value );
+            node = doc.SelectSingleNode("//info/entry/commit/@revision");
+            if (node != null) m_nLastChangedRev = int.Parse(node.Value);
+            node = doc.SelectSingleNode("//info/entry/commit/author");
+            if (node != null) m_strLastChangedAuthor = node.InnerText;
+            node = doc.SelectSingleNode("//info/entry/commit/date");
+            if (node != null) m_LastChangedDate = DateTime.Parse(node.InnerText);
+            node = doc.SelectSingleNode("//info/entry/wc-info/schedule");
+            if (node != null)
+            {
+                switch (node.InnerText)
+                {
+                    case "normal":
+                        m_eSchedule = MSBuild.Community.Tasks.Subversion.Schedule.normal;
+                        break;
+                    default:
+                        m_eSchedule = MSBuild.Community.Tasks.Subversion.Schedule.unknown;
+                        break;
+                }
+            }
             return bSuccess;
         }
 
+/*
         /// <summary>
         /// "svn.exe info" prints out key/value pairs separated by a colon.
         /// </summary>
@@ -159,6 +206,7 @@
 
             return true;
         }
+*/
 
         /// <summary>
         /// Return the repository root or null if not set by Subversion.
@@ -266,6 +314,7 @@
             }
         }
 
+        StringBuilder sbXml = new StringBuilder();
         /// <summary>
         /// Parse the text output from the command and log the lines.
         /// </summary>
@@ -276,9 +325,12 @@
             // The base implementation just seems to log out the lines which is really chatty.
             // base.LogEventsFromTextOutput(singleLine, messageImportance);
 
+            sbXml.AppendLine(singleLine);
+            return;
+/*
             string key;
             string value;
-
+           
             if (ExtractKeyValuePair(singleLine, out key, out value))
             {
                 if (key == "URL")
@@ -336,6 +388,17 @@
                     }
                 }
             }
+ */
         }
     }
 }
+
+/*
+ * Updated  kazuhiko kikuchi <kazuk.dll@gmail.com> on 2009/09/15
+ *
+ * use "svn info --xml" output ( previous use "svn info" )
+ *
+ *   "snv info" output was localized by user locale.
+ *   but "snv info --xml" output was not localized (stable).
+ *
+ */
\ No newline at end of file
Index: Source/MSBuild.Community.Tasks/Subversion/SvnVersion.cs
===================================================================
--- Source/MSBuild.Community.Tasks/Subversion/SvnVersion.cs (revision 255)
+++ Source/MSBuild.Community.Tasks/Subversion/SvnVersion.cs (working copy)
@@ -35,6 +35,7 @@
 using System.IO;
 using Microsoft.Build.Utilities;
 using Microsoft.Build.Framework;
+using Microsoft.Win32;
 
 // $Id$
 
@@ -191,7 +192,31 @@
   /// <returns>The name of the executable file to run.</returns>
   protected override string ToolName
   {
-   get { return "svnversion.exe"; }
+            get
+            {
+                RegistryKey hklm = Registry.CurrentUser;
+                RegistryKey key = hklm.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\svn.exe", false);
+                if (key != null)
+                {
+                    object obj = key.GetValue(null); // Default value
+                    string svnPath = (string) obj;
+                    return Path.Combine(Path.GetDirectoryName(svnPath), "svnversion.exe");
+                }
+                else
+                {
+                    // Not in the registry
+                    const string defaultPath = "C:\\Program Files\\Subversion\\bin\\svnversion.exe";
+                    if (File.Exists(defaultPath))
+                    {
+                        return defaultPath;
+                    }
+                    else
+                    {
+                        // Let's hope it's in the path
+                        return "svnversion.exe";
+                    }
+                }
+            }
   }
 
   /// <summary>
Index: Source/Subversion.proj
===================================================================
--- Source/Subversion.proj (revision 255)
+++ Source/Subversion.proj (working copy)
@@ -3,66 +3,49 @@
   <!-- $Id$ -->
   <PropertyGroup>
     <MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\MSBuild.Community.Tasks\bin\Debug</MSBuildCommunityTasksPath>
-    <LastUpdate>Dienstag, 10. Januar 2006</LastUpdate>
+    <LastUpdate>2006年9月15日</LastUpdate>
     <TestUpdate>Test from Task.proj</TestUpdate>
   </PropertyGroup>
-
   <Import Project="$(MSBuildProjectDirectory)\MSBuild.Community.Tasks\MSBuild.Community.Tasks.Targets" />
-
   <Target Name="Version">
     <SvnVersion LocalPath="$(MSBuildProjectDirectory)">
       <Output TaskParameter="Revision" PropertyName="Revision" />
     </SvnVersion>
-
     <Message Text="Revision: $(Revision)" />
   </Target>
-
   <Target Name="Export">
     <MakeDir Directories="$(MSBuildProjectDirectory)\Test" />
     <RemoveDir Directories="$(MSBuildProjectDirectory)\Test\Export" />
-
-    <SvnExport RepositoryPath="file:///d:/svn/repo/Test/trunk"
-               LocalPath="$(MSBuildProjectDirectory)\Test\Export">
+    <SvnExport RepositoryPath="file:///d:/svn/repo/Test/trunk" LocalPath="$(MSBuildProjectDirectory)\Test\Export">
       <Output TaskParameter="Revision" PropertyName="Revision" />
     </SvnExport>
-
     <Message Text="Revision: $(Revision)" />
   </Target>
-
   <Target Name="Checkout">
     <RemoveDir Directories="$(MSBuildProjectDirectory)\Test\Checkout" />
-
-    <SvnCheckout RepositoryPath="file:///d:/svn/repo/Test/trunk"
-                 LocalPath="$(MSBuildProjectDirectory)\Test\Checkout">
+    <SvnCheckout RepositoryPath="file:///d:/svn/repo/Test/trunk" LocalPath="$(MSBuildProjectDirectory)\Test\Checkout">
       <Output TaskParameter="Revision" PropertyName="Revision" />
     </SvnCheckout>
-
     <Message Text="Revision: $(Revision)" />
   </Target>
-
   <Target Name="Update" DependsOnTargets="Checkout">
     <SvnUpdate LocalPath="$(MSBuildProjectDirectory)\Test\Checkout">
       <Output TaskParameter="Revision" PropertyName="Revision" />
     </SvnUpdate>
     <Message Text="Revision: $(Revision)" />
   </Target>
-
   <ItemGroup>
     <CommitFiles Include="$(MSBuildProjectDirectory)\Test\Checkout\test.txt" />
     <CommitFiles Include="$(MSBuildProjectDirectory)\Test\Checkout\Blah.txt" />
   </ItemGroup>
-
   <Target Name="Commit" DependsOnTargets="Checkout">
     <WriteLinesToFile File="$(MSBuildProjectDirectory)\Test\Checkout\test.txt" Lines="This is a test append." />
     <WriteLinesToFile File="$(MSBuildProjectDirectory)\Test\Checkout\Blah.txt" Lines="This is a test append." />
-
     <SvnCommit Targets="@(CommitFiles)" Message="Auto commit from MSBuild.">
       <Output TaskParameter="Revision" PropertyName="Revision" />
     </SvnCommit>
-
     <Message Text="Revision: $(Revision)" />
   </Target>
-
   <Target Name="Info" DependsOnTargets="Checkout">
     <SvnInfo LocalPath=".">
       <Output TaskParameter="RepositoryRoot" PropertyName="RepositoryRoot" />
@@ -81,7 +64,6 @@
     <Message Text="NodeKind: $(NodeKind)" />
     <Message Text="RepositoryUuid: $(RepositoryUuid)" />
   </Target>
-
   <Target Name="All">
     <CallTarget Targets="Version" />
     <CallTarget Targets="Export" />

投稿日時 : 2006年9月15日 18:29


コメントを追加

タイトル
名前
URL
コメント