add NuGet smaple extension code, create NuGet runner wrapper
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Wed, 13 Jul 2011 14:19:45 +0000 (18:19 +0400)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Wed, 13 Jul 2011 14:19:45 +0000 (18:19 +0400)
.gitignore
nuget-extensions/nuget-commands/nuget-commands.csproj
nuget-extensions/nuget-commands/src/NuGetTeamCityListCommand.cs [new file with mode: 0644]
nuget-extensions/nuget-extensions.sln
nuget-extensions/nuget-runner/Properties/AssemblyInfo.cs [new file with mode: 0644]
nuget-extensions/nuget-runner/nuget-runner.csproj [new file with mode: 0644]
nuget-extensions/nuget-runner/src/Program.cs [new file with mode: 0644]

index cc15733f866cbbcbc84115fc01430adc083fd650..bbfdd9916984435611eefe24e23bad068340bfb3 100644 (file)
@@ -5,4 +5,5 @@ nuget-extensions/**/obj
 nuget-extensions/**.suo\r
 nuget-extensions/**/*.user\r
 nuget-extensions/*.user\r
+nuget-extensions/*.cache\r
 nuget-extensions/_ReSharper*\r
index c416411bdff708b011d7e3c557787daa4b585dce..fb870f02b87793c58b3d52f73fa38b41c970f695 100644 (file)
@@ -31,6 +31,9 @@
     <WarningLevel>4</WarningLevel>\r
   </PropertyGroup>\r
   <ItemGroup>\r
+    <Reference Include="NuGet">\r
+      <HintPath>..\lib\nuget\1.4\NuGet.exe</HintPath>\r
+    </Reference>\r
     <Reference Include="System" />\r
     <Reference Include="System.Core" />\r
     <Reference Include="System.Xml.Linq" />\r
@@ -40,7 +43,7 @@
     <Reference Include="System.Xml" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <Compile Include="src\Class1.cs" />\r
+    <Compile Include="src\NuGetTeamCityListCommand.cs" />\r
     <Compile Include="Properties\AssemblyInfo.cs" />\r
   </ItemGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
diff --git a/nuget-extensions/nuget-commands/src/NuGetTeamCityListCommand.cs b/nuget-extensions/nuget-commands/src/NuGetTeamCityListCommand.cs
new file mode 100644 (file)
index 0000000..973fe09
--- /dev/null
@@ -0,0 +1,29 @@
+using System.Collections.Generic;\r
+using NuGet;\r
+using NuGet.Commands;\r
+\r
+namespace JetBrains.TeamCity.NuGet.ExtendedCommands\r
+{\r
+  [Command("TeamCity.List", "Lists packages for given Id with parsable output")]\r
+  public class NuGetTeamCityListCommand : Command\r
+  {\r
+    private readonly List<string> mySources = new List<string>();\r
+\r
+    [Option("Sources to search for package", AltName = "s")]\r
+    public ICollection<string> Source { get { return mySources; } }\r
+\r
+    [Option("Package Id to check for version update")]\r
+    public string Id { get; set; }\r
+\r
+    [Option("NuGet Version Spec to constraint versions to be checked. Optional")]\r
+    public string Version { get; set; }\r
+\r
+    public override void ExecuteCommand()\r
+    {\r
+      System.Console.Out.WriteLine("TeamCity NuGet List command.");\r
+      System.Console.Out.WriteLine("Sources: {0}", string.Join(", ", mySources.ToArray()));\r
+      System.Console.Out.WriteLine("Package Id: {0}", Id ?? "<null>");\r
+      System.Console.Out.WriteLine("Version: {0}", Version ?? "<null>");\r
+    }\r
+  }\r
+}\r
index 0cf36b985434f8d0503bdeaad3e146223bd46c8c..5f9cfe944e32c39460c903b121cad1a1b3ba3e51 100644 (file)
@@ -3,16 +3,38 @@ Microsoft Visual Studio Solution File, Format Version 11.00
 # Visual Studio 2010\r
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nuget-commands", "nuget-commands\nuget-commands.csproj", "{8FA969EA-85C0-464E-9745-66B9820121A9}"\r
 EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nuget-runner", "nuget-runner\nuget-runner.csproj", "{B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}"\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
                Debug|Any CPU = Debug|Any CPU\r
+               Debug|Mixed Platforms = Debug|Mixed Platforms\r
+               Debug|x86 = Debug|x86\r
                Release|Any CPU = Release|Any CPU\r
+               Release|Mixed Platforms = Release|Mixed Platforms\r
+               Release|x86 = Release|x86\r
        EndGlobalSection\r
        GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
                {8FA969EA-85C0-464E-9745-66B9820121A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
                {8FA969EA-85C0-464E-9745-66B9820121A9}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {8FA969EA-85C0-464E-9745-66B9820121A9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU\r
+               {8FA969EA-85C0-464E-9745-66B9820121A9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU\r
+               {8FA969EA-85C0-464E-9745-66B9820121A9}.Debug|x86.ActiveCfg = Debug|Any CPU\r
                {8FA969EA-85C0-464E-9745-66B9820121A9}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
                {8FA969EA-85C0-464E-9745-66B9820121A9}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {8FA969EA-85C0-464E-9745-66B9820121A9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU\r
+               {8FA969EA-85C0-464E-9745-66B9820121A9}.Release|Mixed Platforms.Build.0 = Release|Any CPU\r
+               {8FA969EA-85C0-464E-9745-66B9820121A9}.Release|x86.ActiveCfg = Release|Any CPU\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Debug|Any CPU.ActiveCfg = Debug|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Debug|Mixed Platforms.Build.0 = Debug|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Debug|x86.ActiveCfg = Debug|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Debug|x86.Build.0 = Debug|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Release|Any CPU.ActiveCfg = Release|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Release|Mixed Platforms.ActiveCfg = Release|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Release|Mixed Platforms.Build.0 = Release|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Release|x86.ActiveCfg = Release|x86\r
+               {B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}.Release|x86.Build.0 = Release|x86\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
diff --git a/nuget-extensions/nuget-runner/Properties/AssemblyInfo.cs b/nuget-extensions/nuget-runner/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..b666263
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// General Information about an assembly is controlled through the following \r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle("JetBrains TeamCity NuGet Runner")]\r
+[assembly: AssemblyDescription("NuGet commands for TeamCity NuGet integration")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("JetBrains, s.r.o.")]\r
+[assembly: AssemblyProduct("TeamCity NuGet integration")]\r
+[assembly: AssemblyCopyright("Copyright © JetBrains 2011")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+\r
+// Setting ComVisible to false makes the types in this assembly not visible \r
+// to COM components.  If you need to access a type in this assembly from \r
+// COM, set the ComVisible attribute to true on that type.\r
+[assembly: ComVisible(false)]\r
+\r
+// The following GUID is for the ID of the typelib if this project is exposed to COM\r
+[assembly: Guid("f29a877e-de2c-4eb4-8908-85b9808253c4")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+//      Major Version\r
+//      Minor Version \r
+//      Build Number\r
+//      Revision\r
+//\r
+// You can specify all the values or you can default the Build and Revision Numbers \r
+// by using the '*' as shown below:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion("1.0.0.0")]\r
+[assembly: AssemblyFileVersion("1.0.0.0")]\r
diff --git a/nuget-extensions/nuget-runner/nuget-runner.csproj b/nuget-extensions/nuget-runner/nuget-runner.csproj
new file mode 100644 (file)
index 0000000..2686d74
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>\r
+    <ProductVersion>8.0.30703</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{B79E58CB-F8FD-4CD6-8B62-10EBA0DF592B}</ProjectGuid>\r
+    <OutputType>Exe</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>nuget_runner</RootNamespace>\r
+    <AssemblyName>nuget-runner</AssemblyName>\r
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\r
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>\r
+    <FileAlignment>512</FileAlignment>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">\r
+    <PlatformTarget>x86</PlatformTarget>\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">\r
+    <PlatformTarget>x86</PlatformTarget>\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Core" />\r
+    <Reference Include="System.Xml.Linq" />\r
+    <Reference Include="System.Data.DataSetExtensions" />\r
+    <Reference Include="Microsoft.CSharp" />\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="src\Program.cs" />\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+</Project>
\ No newline at end of file
diff --git a/nuget-extensions/nuget-runner/src/Program.cs b/nuget-extensions/nuget-runner/src/Program.cs
new file mode 100644 (file)
index 0000000..d883be7
--- /dev/null
@@ -0,0 +1,34 @@
+using System;\r
+using System.Linq;\r
+using System.Reflection;\r
+\r
+namespace nuget_runner\r
+{\r
+  public class Program\r
+  {\r
+    static int Main(string[] args)\r
+    {\r
+      Console.Out.WriteLine("JetBrains TeamCity NuGet Runner " + typeof(Program).Assembly.GetName().Version);\r
+      Console.Out.WriteLine("Starting NuGet with additional commands");\r
+      if (args.Length < 2) return Usage();\r
+\r
+      string nuget = args[0];\r
+      string[] nugetArgs = args.Skip(1).ToArray();\r
+\r
+      var nugetAssembly = Assembly.LoadFrom(nuget);\r
+\r
+      var result = nugetAssembly.EntryPoint.Invoke(null, new[] {nugetArgs});\r
+\r
+      if (result is int)\r
+        return (int) result;\r
+\r
+      return 0;\r
+    }\r
+\r
+    static int Usage()\r
+    {\r
+      Console.Out.WriteLine("JetBrains.TeamCity.NuGetRunner.exe <path to nuget> <nuget parameters>");\r
+      return 1;\r
+    }\r
+  }\r
+}\r