Implemented NuGet package building

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 11 years ago
parent 454c1dba33
commit 6b59eddf51
  1. 7
      DotNetBuilder/MicroBuildServer.DotNetBuilder.csproj
  2. 18
      DotNetBuilder/NuGetRequest.cs
  3. 184
      DotNetBuilder/NuGetter.cs
  4. 4
      DotNetBuilder/Program.cs

@ -15,7 +15,7 @@
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@ -40,6 +40,9 @@
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NuGet">
<HintPath>..\.nuget\NuGet.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@ -51,6 +54,8 @@
<ItemGroup>
<Compile Include="Compiler.cs" />
<Compile Include="CompileRequest.cs" />
<Compile Include="NuGetRequest.cs" />
<Compile Include="NuGetter.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Response.cs" />

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MicroBuildServer.DotNetBuilder
{
class NuGetRequest
{
public string BaseDirectory { get; set; }
public string SpecPath { get; set; }
public string OutputDirectory { get; set; }
public string Version { get; set; }
}
}

@ -0,0 +1,184 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NuGet;
using NuGet.Common;
namespace MicroBuildServer.DotNetBuilder
{
static class NuGetter
{
private class Console : IConsole
{
public readonly IList<Response.Message> Messages = new List<Response.Message>();
public bool Confirm(string description)
{
throw new NotImplementedException();
}
public int CursorLeft
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public bool IsNonInteractive
{
get { return true; }
set { throw new NotImplementedException(); }
}
public void PrintJustified(int startIndex, string text, int maxWidth)
{
throw new NotImplementedException();
}
public void PrintJustified(int startIndex, string text)
{
throw new NotImplementedException();
}
public ConsoleKeyInfo ReadKey()
{
throw new NotImplementedException();
}
public string ReadLine()
{
throw new NotImplementedException();
}
public void ReadSecureString(System.Security.SecureString secureString)
{
throw new NotImplementedException();
}
public Verbosity Verbosity
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public int WindowWidth
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public void Write(string format, params object[] args)
{
Write(string.Format(format, args));
}
public void Write(string value)
{
Messages.Add(Response.Message.CreateInfo(value));
}
public void Write(object value)
{
Write(value.ToString());
}
public void WriteError(string format, params object[] args)
{
WriteError(string.Format(format, args));
}
public void WriteError(string value)
{
Messages.Add(Response.Message.CreateError(value));
}
public void WriteError(object value)
{
WriteError(value.ToString());
}
public void WriteLine(ConsoleColor color, string value, params object[] args)
{
throw new NotImplementedException();
}
public void WriteLine(string format, params object[] args)
{
Write(format, args);
}
public void WriteLine(string value)
{
Write(value);
}
public void WriteLine(object value)
{
Write(value);
}
public void WriteLine()
{
}
public void WriteWarning(bool prependWarningText, string value, params object[] args)
{
throw new NotImplementedException();
}
public void WriteWarning(string value, params object[] args)
{
WriteWarning(string.Format(value, args));
}
public void WriteWarning(bool prependWarningText, string value)
{
throw new NotImplementedException();
}
public void WriteWarning(string value)
{
Messages.Add(Response.Message.CreateWarn(value));
}
public void Log(MessageLevel level, string message, params object[] args)
{
switch (level)
{
case MessageLevel.Error:
WriteError(message, args);
return;
case MessageLevel.Warning:
WriteWarning(message, args);
return;
case MessageLevel.Info:
Write(message, args);
return;
}
}
public FileConflictResolution ResolveFileConflict(string message)
{
throw new NotImplementedException();
}
}
public static Response Publish(NuGetRequest request)
{
var console = new Console();
var command = new NuGet.Commands.PackCommand
{
BasePath = request.BaseDirectory,
OutputDirectory = request.OutputDirectory,
Version = request.Version,
Console = console,
Verbosity = Verbosity.Detailed,
Rules = new IPackageRule[0],
};
command.Arguments.Add(request.SpecPath);
command.Execute();
return new Response { Messages = console.Messages.ToArray() };
}
}
}

@ -23,6 +23,8 @@ namespace MicroBuildServer.DotNetBuilder
return Compiler.Compile(JsonConvert.DeserializeObject<CompileRequest>(input));
case "test":
return Test(JsonConvert.DeserializeObject<TestRequest>(input));
case "nuget":
return NuGetter.Publish(JsonConvert.DeserializeObject<NuGetRequest>(input));
default:
throw new ApplicationException("Unsupported type '" + args[0] + "'");
}
@ -37,7 +39,7 @@ namespace MicroBuildServer.DotNetBuilder
{
var input = Console.In.ReadToEnd();
var result = Process(input, args);
Console.Write(JsonConvert.SerializeObject(result));
Console.Write(JsonConvert.SerializeObject(result, Formatting.Indented));
}
}
}

Loading…
Cancel
Save