add NuGet smaple extension code, create NuGet runner wrapper
[teamcity/dotNetPackagesSupport.git] / nuget-extensions / nuget-runner / src / Program.cs
1 using System;\r
2 using System.Linq;\r
3 using System.Reflection;\r
4 \r
5 namespace nuget_runner\r
6 {\r
7   public class Program\r
8   {\r
9     static int Main(string[] args)\r
10     {\r
11       Console.Out.WriteLine("JetBrains TeamCity NuGet Runner " + typeof(Program).Assembly.GetName().Version);\r
12       Console.Out.WriteLine("Starting NuGet with additional commands");\r
13       if (args.Length < 2) return Usage();\r
14 \r
15       string nuget = args[0];\r
16       string[] nugetArgs = args.Skip(1).ToArray();\r
17 \r
18       var nugetAssembly = Assembly.LoadFrom(nuget);\r
19 \r
20       var result = nugetAssembly.EntryPoint.Invoke(null, new[] {nugetArgs});\r
21 \r
22       if (result is int)\r
23         return (int) result;\r
24 \r
25       return 0;\r
26     }\r
27 \r
28     static int Usage()\r
29     {\r
30       Console.Out.WriteLine("JetBrains.TeamCity.NuGetRunner.exe <path to nuget> <nuget parameters>");\r
31       return 1;\r
32     }\r
33   }\r
34 }\r