Browse Source

NuGet 4 support (with custom-built NuGet.exe v4)

master
Inga 🏳‍🌈 6 years ago
parent
commit
26137d503a
  1. BIN
      Binaries/NuGet.exe
  2. 34
      DotNetBuilder/MicroBuildServer.DotNetBuilder.csproj
  3. 102
      DotNetBuilder/NuGetter.cs
  4. 8
      DotNetBuilder/app.config
  5. 8
      DotNetBuilder/packages.config

BIN
Binaries/NuGet.exe

Binary file not shown.

34
DotNetBuilder/MicroBuildServer.DotNetBuilder.csproj

@ -60,12 +60,24 @@ @@ -60,12 +60,24 @@
<HintPath>..\packages\Microsoft.Extensions.CommandLineUtils.1.1.0\lib\net451\Microsoft.Extensions.CommandLineUtils.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Setup.Configuration.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.1.8.24\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.Web.XmlTransform, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet">
<HintPath>..\packages\NuGet.CommandLine.3.5.0\tools\NuGet.exe</HintPath>
<Reference Include="NuGet, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\Binaries\NuGet.exe</HintPath>
</Reference>
<Reference Include="NuGet.Build.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Build.Tasks.4.0.0\lib\net45\NuGet.Build.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Client.4.0.0\lib\net45\NuGet.Client.dll</HintPath>
@ -77,7 +89,6 @@ @@ -77,7 +89,6 @@
</Reference>
<Reference Include="NuGet.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Common.4.0.0\lib\net45\NuGet.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Configuration.4.0.0\lib\net45\NuGet.Configuration.dll</HintPath>
@ -87,6 +98,10 @@ @@ -87,6 +98,10 @@
<HintPath>..\packages\NuGet.ContentModel.4.0.0\lib\net45\NuGet.ContentModel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.Core, Version=2.14.0.832, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Core.2.14.0\lib\net40-Client\NuGet.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.DependencyResolver.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.DependencyResolver.Core.4.0.0\lib\net45\NuGet.DependencyResolver.Core.dll</HintPath>
<Private>True</Private>
@ -99,6 +114,10 @@ @@ -99,6 +114,10 @@
<HintPath>..\packages\NuGet.LibraryModel.4.0.0\lib\net45\NuGet.LibraryModel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.PackageManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.PackageManagement.4.0.0\lib\net45\NuGet.PackageManagement.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.Packaging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Packaging.4.0.0\lib\net45\NuGet.Packaging.dll</HintPath>
<Private>True</Private>
@ -111,6 +130,10 @@ @@ -111,6 +130,10 @@
<HintPath>..\packages\NuGet.Packaging.Core.Types.4.0.0\lib\net45\NuGet.Packaging.Core.Types.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.ProjectManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.ProjectManagement.4.0.0\lib\net45\NuGet.ProjectManagement.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.ProjectModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.ProjectModel.4.0.0\lib\net45\NuGet.ProjectModel.dll</HintPath>
<Private>True</Private>
@ -127,6 +150,10 @@ @@ -127,6 +150,10 @@
<HintPath>..\packages\NuGet.Repositories.4.0.0\lib\net45\NuGet.Repositories.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.Resolver, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.Resolver.4.0.0\lib\net45\NuGet.Resolver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NuGet.RuntimeModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\NuGet.RuntimeModel.4.0.0\lib\net45\NuGet.RuntimeModel.dll</HintPath>
<Private>True</Private>
@ -167,6 +194,7 @@ @@ -167,6 +194,7 @@
<HintPath>..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.IO.Compression" />

102
DotNetBuilder/NuGetter.cs

@ -1,8 +1,5 @@ @@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using NuGet;
using NuGet.CommandLine;
using NuGet.Common;
@ -10,111 +7,117 @@ namespace MicroBuildServer.DotNetBuilder @@ -10,111 +7,117 @@ namespace MicroBuildServer.DotNetBuilder
{
static class NuGetter
{
private class Console : IConsole
private class Console : NuGet.CommandLine.IConsole, NuGet.Common.ILogger
{
public readonly Messages Messages = new Messages();
public int CursorLeft
int IConsole.CursorLeft
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public bool IsNonInteractive
bool IConsole.IsNonInteractive
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public Verbosity Verbosity
Verbosity IConsole.Verbosity
{
get { return Verbosity.Detailed; }
set { throw new NotImplementedException(); }
}
public int WindowWidth
int IConsole.WindowWidth
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public bool Confirm(string description)
bool IConsole.Confirm(string description)
{
throw new NotImplementedException();
}
public void LogDebug(string data) => this.Messages.Add(Message.CreateInfo(data));
public void LogError(string data) => this.Messages.Add(Message.CreateError(data));
public void LogErrorSummary(string data) => this.Messages.Add(Message.CreateError(data));
public void LogInformation(string data) => this.Messages.Add(Message.CreateInfo(data));
public void LogInformationSummary(string data) => this.Messages.Add(Message.CreateInfo(data));
public void LogMinimal(string data) => this.Messages.Add(Message.CreateInfo(data));
public void LogVerbose(string data) => this.Messages.Add(Message.CreateInfo(data));
public void LogWarning(string data) => this.Messages.Add(Message.CreateWarn(data));
public void PrintJustified(int startIndex, string text)
void IConsole.PrintJustified(int startIndex, string text)
{
throw new NotImplementedException();
}
public void PrintJustified(int startIndex, string text, int maxWidth)
void IConsole.PrintJustified(int startIndex, string text, int maxWidth)
{
throw new NotImplementedException();
}
public ConsoleKeyInfo ReadKey()
ConsoleKeyInfo IConsole.ReadKey()
{
throw new NotImplementedException();
}
public string ReadLine()
string IConsole.ReadLine()
{
throw new NotImplementedException();
}
public void ReadSecureString(SecureString secureString)
void IConsole.ReadSecureString(SecureString secureString)
{
throw new NotImplementedException();
}
public void Write(string value) => this.Messages.Add(Message.CreateInfo(value));
void IConsole.Write(string value) => this.WriteInfo(value);
public void Write(object value) => this.Write(value.ToString());
void IConsole.Write(object value) => this.WriteInfo(value.ToString());
public void Write(string format, params object[] args) => this.Write(string.Format(format, args));
void IConsole.Write(string format, params object[] args) => this.WriteInfo(string.Format(format, args));
public void WriteError(string value) => this.Messages.Add(Message.CreateError(value));
void IConsole.WriteError(string value) => this.WriteError(value);
public void WriteError(object value) => this.WriteError(value.ToString());
void IConsole.WriteError(object value) => this.WriteError(value.ToString());
public void WriteError(string format, params object[] args) => this.WriteError(string.Format(format, args));
void IConsole.WriteError(string format, params object[] args) => this.WriteError(string.Format(format, args));
public void WriteLine()
void IConsole.WriteLine()
{
}
public void WriteLine(string value) => this.Write(value);
void IConsole.WriteLine(string value) => this.WriteInfo(value);
public void WriteLine(object value) => this.Write(value);
void IConsole.WriteLine(object value) => this.WriteInfo(value.ToString());
public void WriteLine(string format, params object[] args) => this.Write(format, args);
void IConsole.WriteLine(string format, params object[] args) => this.WriteInfo(string.Format(format, args));
public void WriteLine(ConsoleColor color, string value, params object[] args) => this.Write(value, args);
void IConsole.WriteLine(ConsoleColor color, string value, params object[] args) => this.WriteInfo(string.Format(value, args));
public void WriteWarning(string value) => this.Messages.Add(Message.CreateWarn(value));
void IConsole.WriteWarning(string value) => this.WriteWarning(value);
void IConsole.WriteWarning(string value, params object[] args) => this.WriteWarning(string.Format(value, args));
void IConsole.WriteWarning(bool prependWarningText, string value) => this.WriteWarning(value);
public void WriteWarning(string value, params object[] args) => this.WriteWarning(string.Format(value, args));
void IConsole.WriteWarning(bool prependWarningText, string value, params object[] args) => this.WriteWarning(string.Format(value, args));
public void WriteWarning(bool prependWarningText, string value) => this.WriteWarning(value);
void ILogger.LogDebug(string data) => this.WriteInfo(data);
public void WriteWarning(bool prependWarningText, string value, params object[] args) => this.WriteWarning(value, args);
void ILogger.LogError(string data) => this.WriteError(data);
void ILogger.LogErrorSummary(string data) => this.WriteError(data);
void ILogger.LogInformation(string data) => this.WriteInfo(data);
void ILogger.LogInformationSummary(string data) => this.WriteInfo(data);
void ILogger.LogMinimal(string data) => this.WriteInfo(data);
void ILogger.LogVerbose(string data) => this.WriteInfo(data);
void ILogger.LogWarning(string data) => this.WriteWarning(data);
public void WriteInfo(string value) => this.Messages.Add(Message.CreateInfo(value));
public void WriteWarning(string value) => this.Messages.Add(Message.CreateWarn(value));
public void WriteError(string value) => this.Messages.Add(Message.CreateError(value));
}
public static Response Pack(NuGetPackRequest request)
@ -126,6 +129,7 @@ namespace MicroBuildServer.DotNetBuilder @@ -126,6 +129,7 @@ namespace MicroBuildServer.DotNetBuilder
OutputDirectory = PathTools.OptimizePath(request.OutputDirectory),
Version = request.Version,
Console = console,
CurrentDirectory = request.BaseDirectory,
Verbosity = Verbosity.Detailed,
};
command.Arguments.Add(request.SpecPath);
@ -136,7 +140,7 @@ namespace MicroBuildServer.DotNetBuilder @@ -136,7 +140,7 @@ namespace MicroBuildServer.DotNetBuilder
}
catch (Exception e)
{
console.WriteError(e);
console.WriteError(e.ToString());
}
return new Response(console.Messages);
@ -160,7 +164,7 @@ namespace MicroBuildServer.DotNetBuilder @@ -160,7 +164,7 @@ namespace MicroBuildServer.DotNetBuilder
}
catch (Exception e)
{
console.WriteError(e);
console.WriteError(e.ToString());
}
return new Response(console.Messages);
@ -169,10 +173,10 @@ namespace MicroBuildServer.DotNetBuilder @@ -169,10 +173,10 @@ namespace MicroBuildServer.DotNetBuilder
public static Response Restore(NuGetRestoreRequest request)
{
var console = new Console();
PackageBuilder builder = new PackageBuilder();
var command = new RestoreCommand
{
Console = console,
CurrentDirectory = request.BaseDirectory,
Verbosity = Verbosity.Detailed,
};
command.Arguments.Add(request.SolutionPath);
@ -183,7 +187,7 @@ namespace MicroBuildServer.DotNetBuilder @@ -183,7 +187,7 @@ namespace MicroBuildServer.DotNetBuilder
}
catch (Exception e)
{
console.WriteError(e);
console.WriteError(e.ToString());
}
return new Response(console.Messages);

8
DotNetBuilder/app.config

@ -30,6 +30,14 @@ @@ -30,6 +30,14 @@
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NuGet" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="3.5.0.1996" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NuGet.Common" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />

8
DotNetBuilder/packages.config

@ -6,23 +6,29 @@ @@ -6,23 +6,29 @@
<package id="Microsoft.Build.Tasks.Core" version="15.1.548" targetFramework="net46" />
<package id="Microsoft.Build.Utilities.Core" version="15.1.548" targetFramework="net46" />
<package id="Microsoft.Extensions.CommandLineUtils" version="1.1.0" targetFramework="net46" />
<package id="Microsoft.VisualStudio.Setup.Configuration.Interop" version="1.8.24" targetFramework="net46" developmentDependency="true" />
<package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net46" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net46" />
<package id="NuGet.Build.Tasks" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Client" version="4.0.0" targetFramework="net46" />
<package id="NuGet.CommandLine" version="3.5.0" targetFramework="net46" developmentDependency="true" />
<package id="NuGet.Commands" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Common" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Configuration" version="4.0.0" targetFramework="net46" />
<package id="NuGet.ContentModel" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Core" version="2.14.0" targetFramework="net46" />
<package id="NuGet.DependencyResolver.Core" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Frameworks" version="4.0.0" targetFramework="net46" />
<package id="NuGet.LibraryModel" version="4.0.0" targetFramework="net46" />
<package id="NuGet.PackageManagement" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Packaging" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Packaging.Core" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Packaging.Core.Types" version="4.0.0" targetFramework="net46" />
<package id="NuGet.ProjectManagement" version="4.0.0" targetFramework="net46" />
<package id="NuGet.ProjectModel" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Protocol.Core.Types" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Protocol.Core.v3" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Repositories" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Resolver" version="4.0.0" targetFramework="net46" />
<package id="NuGet.RuntimeModel" version="4.0.0" targetFramework="net46" />
<package id="NuGet.Versioning" version="4.0.0" targetFramework="net46" />
<package id="NUnit" version="2.6.3" targetFramework="net4" />

Loading…
Cancel
Save