mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fixing Velopack.Build
Fixed issue with HttpClient handler not forwarding to the regular handler. Fixed MSBuild property issue. Fixed NRE when publishing Uno app. Better exception reporting.
This commit is contained in:
@@ -93,48 +93,53 @@ public class PackTask : MSBuildAsyncTask
|
||||
protected override async Task<bool> ExecuteAsync()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Launch();
|
||||
HelperFile.ClearSearchPaths();
|
||||
var searchPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "..", "..", "vendor"));
|
||||
HelperFile.AddSearchPath(searchPath);
|
||||
try {
|
||||
HelperFile.ClearSearchPaths();
|
||||
var searchPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "..", "..", "vendor"));
|
||||
HelperFile.AddSearchPath(searchPath);
|
||||
|
||||
if (VelopackRuntimeInfo.IsWindows) {
|
||||
var options = this.ToWinPackOptions();
|
||||
if (VelopackRuntimeInfo.IsWindows) {
|
||||
var options = this.ToWinPackOptions();
|
||||
|
||||
// we can auto-compute the requires runtimes on Windows from the TFM/RID
|
||||
if (!SelfContained && String.IsNullOrEmpty(options.Runtimes)) {
|
||||
// we can auto-compute the requires runtimes on Windows from the TFM/RID
|
||||
if (!SelfContained && String.IsNullOrEmpty(options.Runtimes)) {
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if (TargetFramework.Contains("-")) {
|
||||
TargetFramework = TargetFramework.Substring(0, TargetFramework.IndexOf('-'));
|
||||
}
|
||||
var runtime = Windows.Runtimes.GetRuntimeByName(TargetFramework);
|
||||
if (runtime is Windows.Runtimes.FrameworkInfo) {
|
||||
options.Runtimes = runtime.Id;
|
||||
Log.LogMessage(MessageImportance.High, $"Setup.exe will automatically bootstrap {runtime.DisplayName}.");
|
||||
} else if (!SelfContained && runtime is Windows.Runtimes.DotnetInfo dni && options.TargetRuntime.HasArchitecture) {
|
||||
var rt = new Windows.Runtimes.DotnetInfo(dni.MinVersion.Version, options.TargetRuntime.Architecture);
|
||||
options.Runtimes = rt.Id;
|
||||
Log.LogMessage(MessageImportance.High, $"Setup.exe will automatically bootstrap {rt.DisplayName}.");
|
||||
} else {
|
||||
Log.LogWarning($"No runtime specified and no default runtime found for TFM '{TargetFramework}', please specify runtimes via VelopackRuntimes property in your csproj.");
|
||||
}
|
||||
if (TargetFramework.Contains("-")) {
|
||||
TargetFramework = TargetFramework.Substring(0, TargetFramework.IndexOf('-'));
|
||||
}
|
||||
var runtime = Windows.Runtimes.GetRuntimeByName(TargetFramework);
|
||||
if (runtime is Windows.Runtimes.FrameworkInfo) {
|
||||
options.Runtimes = runtime.Id;
|
||||
Log.LogMessage(MessageImportance.High, $"Setup.exe will automatically bootstrap {runtime.DisplayName}.");
|
||||
} else if (!SelfContained && runtime is Windows.Runtimes.DotnetInfo dni && options.TargetRuntime?.HasArchitecture == true) {
|
||||
var rt = new Windows.Runtimes.DotnetInfo(dni.MinVersion.Version, options.TargetRuntime.Architecture);
|
||||
options.Runtimes = rt.Id;
|
||||
Log.LogMessage(MessageImportance.High, $"Setup.exe will automatically bootstrap {rt.DisplayName}.");
|
||||
} else {
|
||||
Log.LogWarning($"No runtime specified and no default runtime found for TFM '{TargetFramework}', please specify runtimes via VelopackRuntimes property in your csproj.");
|
||||
}
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
|
||||
var runner = new WindowsPackCommandRunner(Logger, Logger);
|
||||
await runner.Run(options).ConfigureAwait(false);
|
||||
} else if (VelopackRuntimeInfo.IsOSX) {
|
||||
var options = this.ToOsxPackOptions();
|
||||
var runner = new OsxPackCommandRunner(Logger, Logger);
|
||||
await runner.Run(options).ConfigureAwait(false);
|
||||
} else if (VelopackRuntimeInfo.IsLinux) {
|
||||
var options = this.ToLinuxPackOptions();
|
||||
var runner = new LinuxPackCommandRunner(Logger, Logger);
|
||||
await runner.Run(options).ConfigureAwait(false);
|
||||
} else {
|
||||
throw new NotSupportedException("Unsupported OS platform: " + VelopackRuntimeInfo.SystemOs.GetOsLongName());
|
||||
}
|
||||
|
||||
var runner = new WindowsPackCommandRunner(Logger, Logger);
|
||||
await runner.Run(options).ConfigureAwait(false);
|
||||
} else if (VelopackRuntimeInfo.IsOSX) {
|
||||
var options = this.ToOsxPackOptions();
|
||||
var runner = new OsxPackCommandRunner(Logger, Logger);
|
||||
await runner.Run(options).ConfigureAwait(false);
|
||||
} else if (VelopackRuntimeInfo.IsLinux) {
|
||||
var options = this.ToLinuxPackOptions();
|
||||
var runner = new LinuxPackCommandRunner(Logger, Logger);
|
||||
await runner.Run(options).ConfigureAwait(false);
|
||||
} else {
|
||||
throw new NotSupportedException("Unsupported OS platform: " + VelopackRuntimeInfo.SystemOs.GetOsLongName());
|
||||
Log.LogMessage(MessageImportance.High, $"{PackId} ({PackVersion}) created in {Path.GetFullPath(ReleaseDir)}");
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
Log.LogErrorFromException(ex, true, true, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.LogMessage(MessageImportance.High, $"{PackId} ({PackVersion}) created in {Path.GetFullPath(ReleaseDir)}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@ namespace Velopack.Build;
|
||||
|
||||
public class PublishTask : MSBuildAsyncTask
|
||||
{
|
||||
private static HttpClient HttpClient { get; } = new(new HmacAuthHttpClientHandler()) {
|
||||
private static HttpClient HttpClient { get; } = new(new HmacAuthHttpClientHandler
|
||||
{
|
||||
InnerHandler = new HttpClientHandler()
|
||||
}) {
|
||||
Timeout = TimeSpan.FromMinutes(10)
|
||||
};
|
||||
|
||||
@@ -24,21 +27,27 @@ public class PublishTask : MSBuildAsyncTask
|
||||
|
||||
protected override async Task<bool> ExecuteAsync()
|
||||
{
|
||||
|
||||
//System.Diagnostics.Debugger.Launch();
|
||||
IVelopackFlowServiceClient client = new VelopackFlowServiceClient(HttpClient, Logger);
|
||||
if (!await client.LoginAsync(new() {
|
||||
AllowDeviceCodeFlow = false,
|
||||
AllowInteractiveLogin = false,
|
||||
VelopackBaseUrl = ServiceUrl,
|
||||
ApiKey = ApiKey
|
||||
}).ConfigureAwait(false)) {
|
||||
Logger.LogWarning("Not logged into Velopack service, skipping publish. Please run vpk login.");
|
||||
try {
|
||||
IVelopackFlowServiceClient client = new VelopackFlowServiceClient(HttpClient, Logger);
|
||||
if (!await client.LoginAsync(new() {
|
||||
AllowDeviceCodeFlow = false,
|
||||
AllowInteractiveLogin = false,
|
||||
VelopackBaseUrl = ServiceUrl,
|
||||
ApiKey = ApiKey
|
||||
}).ConfigureAwait(false)) {
|
||||
Logger.LogWarning("Not logged into Velopack Flow service, skipping publish. Please run vpk login.");
|
||||
return true;
|
||||
}
|
||||
|
||||
await client.UploadLatestReleaseAssetsAsync(Channel, ReleaseDirectory, ServiceUrl)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
Log.LogErrorFromException(ex, true, true, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
await client.UploadLatestReleaseAssetsAsync(Channel, ReleaseDirectory, ServiceUrl)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@
|
||||
<Error Condition="'$(VelopackImplicitPackId)' == 'true'" Text="VelopackPackId must be set explictly before pushing a release to remote." />
|
||||
<PublishTask
|
||||
ReleaseDirectory="$(VelopackReleaseDirectory)"
|
||||
Version="$(VelopackPackVersion)"
|
||||
ServiceUrl="$(VelopackFlowServiceUrl)"
|
||||
ApiKey="$(VelopackFlowApiKey)"
|
||||
Channel="$(VelopackChannel)"
|
||||
/>
|
||||
</Target>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user