mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Run nuget pack in-process and remove nuget.exe
This commit is contained in:
@@ -29,7 +29,6 @@ Copy-Item -Path "$PSScriptRoot\vendor\7zip\*" -Destination "$BinOut" -Recurse
|
||||
Copy-Item -Path "$PSScriptRoot\vendor\wix\*" -Destination "$BinOut" -Recurse
|
||||
Copy-Item "$In\Win32\Setup.exe" -Destination "$BinOut"
|
||||
Copy-Item "$In\Win32\StubExecutable.exe" -Destination "$BinOut"
|
||||
Copy-Item "$PSScriptRoot\vendor\nuget.exe" -Destination "$BinOut"
|
||||
Copy-Item "$PSScriptRoot\vendor\rcedit.exe" -Destination "$BinOut"
|
||||
Copy-Item "$PSScriptRoot\vendor\signtool.exe" -Destination "$BinOut"
|
||||
Copy-Item "$PSScriptRoot\vendor\singlefilehost.exe" -Destination "$BinOut"
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Squirrel
|
||||
public static string WixTemplatePath => FindHelperFile("template.wxs");
|
||||
|
||||
// private so we don't expose paths to internal tools. these should be exposed as a helper function
|
||||
private static string NugetPath => FindHelperFile("nuget.exe");
|
||||
private static string RceditPath => FindHelperFile("rcedit.exe");
|
||||
private static string SevenZipPath => FindHelperFile("7z.exe");
|
||||
private static string SignToolPath => FindHelperFile("signtool.exe");
|
||||
@@ -193,17 +192,6 @@ namespace Squirrel
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task NugetPack(string nuspecPath, string baseDirectory, string outputDirectory)
|
||||
{
|
||||
var args = new string[] { "pack", nuspecPath, "-BasePath", baseDirectory, "-OutputDirectory", outputDirectory };
|
||||
|
||||
Log.Info($"Packing '{baseDirectory}' into nupkg.");
|
||||
var res = await Utility.InvokeProcessAsync(NugetPath, args, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
if (res.ExitCode != 0)
|
||||
throw new Exception($"Failed nuget pack (exit {res.ExitCode}): \r\n " + res.StdOutput);
|
||||
}
|
||||
|
||||
public static async Task ExtractZipToDirectory(string zipFilePath, string outFolder)
|
||||
{
|
||||
try {
|
||||
|
||||
97
src/SquirrelCli/NugetConsole.cs
Normal file
97
src/SquirrelCli/NugetConsole.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NuGet.Commands;
|
||||
using NuGet.Configuration;
|
||||
using NuGet.Packaging;
|
||||
using NuGet.Versioning;
|
||||
using Squirrel.SimpleSplat;
|
||||
|
||||
namespace SquirrelCli
|
||||
{
|
||||
internal class NugetConsole : NuGet.Common.ILogger, IEnableLogger
|
||||
{
|
||||
public void Pack(string nuspecPath, string baseDirectory, string outputDirectory)
|
||||
{
|
||||
this.Log().Info($"Starting to package '{nuspecPath}'");
|
||||
var args = new PackArgs() {
|
||||
Deterministic = true,
|
||||
BasePath = baseDirectory,
|
||||
OutputDirectory = outputDirectory,
|
||||
Path = nuspecPath,
|
||||
Exclude = Enumerable.Empty<string>(),
|
||||
Arguments = Enumerable.Empty<string>(),
|
||||
Logger = this,
|
||||
ExcludeEmptyDirectories = true,
|
||||
NoDefaultExcludes = true,
|
||||
NoPackageAnalysis = true,
|
||||
};
|
||||
|
||||
var c = new PackCommandRunner(args, null);
|
||||
if (!c.RunPackageBuild())
|
||||
throw new Exception("Error creating nuget package.");
|
||||
}
|
||||
|
||||
#region NuGet.Common.ILogger
|
||||
public void Log(NuGet.Common.LogLevel level, string data)
|
||||
{
|
||||
this.Log().Info(data);
|
||||
}
|
||||
|
||||
public void Log(NuGet.Common.ILogMessage message)
|
||||
{
|
||||
this.Log().Info(message.Message);
|
||||
}
|
||||
|
||||
public Task LogAsync(NuGet.Common.LogLevel level, string data)
|
||||
{
|
||||
this.Log().Info(data);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task LogAsync(NuGet.Common.ILogMessage message)
|
||||
{
|
||||
this.Log().Info(message.Message);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void LogDebug(string data)
|
||||
{
|
||||
this.Log().Debug(data);
|
||||
}
|
||||
|
||||
public void LogError(string data)
|
||||
{
|
||||
this.Log().Error(data);
|
||||
}
|
||||
|
||||
public void LogInformation(string data)
|
||||
{
|
||||
this.Log().Info(data);
|
||||
}
|
||||
|
||||
public void LogInformationSummary(string data)
|
||||
{
|
||||
this.Log().Info(data);
|
||||
}
|
||||
|
||||
public void LogMinimal(string data)
|
||||
{
|
||||
this.Log().Info(data);
|
||||
}
|
||||
|
||||
public void LogVerbose(string data)
|
||||
{
|
||||
this.Log().Debug(data);
|
||||
}
|
||||
|
||||
public void LogWarning(string data)
|
||||
{
|
||||
this.Log().Warn(data);
|
||||
}
|
||||
#endregion NuGet.Common.ILogger
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace SquirrelCli
|
||||
var nuspecPath = Path.Combine(tmpDir, options.packId + ".nuspec");
|
||||
File.WriteAllText(nuspecPath, nuspec);
|
||||
|
||||
HelperExe.NugetPack(nuspecPath, options.packDirectory, tmpDir).Wait();
|
||||
new NugetConsole().Pack(nuspecPath, options.packDirectory, tmpDir);
|
||||
|
||||
var nupkgPath = Directory.EnumerateFiles(tmpDir).Where(f => f.EndsWith(".nupkg")).FirstOrDefault();
|
||||
if (nupkgPath == null)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
|
||||
<PackageReference Include="B2Net" Version="0.7.5" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="NuGet.Commands" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -13,12 +13,17 @@
|
||||
<AssemblyOriginatorKeyFile>..\Squirrel.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\src\SquirrelCli\NugetConsole.cs" Link="TestHelpers\NugetConsole.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
|
||||
<PackageReference Include="System.IO.Packaging" Version="5.0.0" />
|
||||
<PackageReference Include="System.IO.Packaging" Version="6.0.0" />
|
||||
<PackageReference Include="NuGet.Commands" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Squirrel.Tests.TestHelpers
|
||||
IntegrationTestHelper.GetPath("fixtures", "NotSquirrelAwareApp.exe"),
|
||||
Path.Combine(targetDir, "NotSquirrelAwareApp.exe"));
|
||||
|
||||
HelperExe.NugetPack(nuspecPath, targetDir, targetDir).GetAwaiter().GetResult();
|
||||
new SquirrelCli.NugetConsole().Pack(nuspecPath, targetDir, targetDir);
|
||||
|
||||
var di = new DirectoryInfo(targetDir);
|
||||
var pkg = di.EnumerateFiles("*.nupkg").First();
|
||||
|
||||
BIN
vendor/NuGet.exe
vendored
BIN
vendor/NuGet.exe
vendored
Binary file not shown.
11
vendor/README.md
vendored
11
vendor/README.md
vendored
@@ -1,12 +1,6 @@
|
||||
# Vendor Binaries
|
||||
This folder contains pre-compiled binaries from a variety of sources. These should be updated periodically.
|
||||
|
||||
<!-- ### Microsoft.NET.HostModel.dll
|
||||
- This is a .NET SDK 6.0.100 binary.
|
||||
- It's purpose is to allow us to re-pack the `Update.exe` single file bundle with a new exe icon.
|
||||
- Can be found in the dotnet SDK at "C:\Program Files\dotnet\sdk\6.0.100\Microsoft.NET.HostModel.dll".
|
||||
- MIT License: https://github.com/dotnet/runtime/blob/main/LICENSE.TXT -->
|
||||
|
||||
### singlefilehost.exe
|
||||
- This is the native exe that has the .net native runtime linked in.
|
||||
- It is also used for re-packing the `Update.exe` binary.
|
||||
@@ -14,11 +8,6 @@ This folder contains pre-compiled binaries from a variety of sources. These shou
|
||||
- Can also be downloaded from NuGet, from here https://www.nuget.org/packages/Microsoft.NETCore.App.Host.win-x86/6.0.0
|
||||
- MIT License: https://github.com/dotnet/runtime/blob/main/LICENSE.TXT
|
||||
|
||||
### nuget.exe
|
||||
- Used with the `pack` command to bundle an application directory into a nuget package, which is then used to create Squirrel releases
|
||||
- Can be found at https://www.nuget.org/downloads
|
||||
- Apache 2.0 License: https://github.com/NuGet/NuGet.Client/blob/dev/LICENSE.txt
|
||||
|
||||
### rcedit.exe
|
||||
- Updates PE resources, like VersionInfo or icons. It is used when generating `Setup.exe` and `Update.exe` to apply the user preferences.
|
||||
- Can be found at https://github.com/electron/rcedit/releases
|
||||
|
||||
Reference in New Issue
Block a user