appveyor: publish self-contained

This commit is contained in:
Ioannis G 2021-01-05 01:50:19 +02:00
parent 499a0abe7f
commit bc3dfd4a73
No known key found for this signature in database
GPG key ID: EAC0E4E5E36AC49E
3 changed files with 17 additions and 19 deletions

View file

@ -94,8 +94,4 @@
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -NoProfile -ExecutionPolicy Bypass -File $(SolutionDir)Scripts\post_build.ps1 $(ConfigurationName) $(SolutionDir) $(TargetPath)" />
</Target>
</Project>

View file

@ -1,13 +1,13 @@
param(
[string]$config = "Release",
[string]$solution,
[string]$targetpath
[string]$solution = (Join-Path $PSScriptRoot ".." -Resolve)
)
Write-Host "Config: $config"
function Build-Version {
if ([string]::IsNullOrEmpty($env:flowVersion)) {
$v = (Get-Command ${TargetPath}).FileVersionInfo.FileVersion
$targetPath = Join-Path $solution "Output/Release/Flow.Launcher.dll" -Resolve
$v = (Get-Command ${targetPath}).FileVersionInfo.FileVersion
} else {
$v = $env:flowVersion
}
@ -75,6 +75,8 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
Write-Host "Packing: $spec"
Write-Host "Input path: $input"
# making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced.
New-Alias Nuget $env:USERPROFILE\.nuget\packages\NuGet.CommandLine\5.4.0\tools\NuGet.exe -Force
# TODO: can we use dotnet pack here?
nuget pack $spec -Version $version -BasePath $input -OutputDirectory $output -Properties Configuration=Release
@ -100,13 +102,14 @@ function Pack-Squirrel-Installer ($path, $version, $output) {
Write-Host "End pack squirrel installer"
}
function IsDotNetCoreAppSelfContainedPublishEvent{
return Test-Path $solution\Output\Release\coreclr.dll
}
function Publish-Self-Contained ($p) {
function FixPublishLastWriteDateTimeError ($solutionPath) {
#Fix error from publishing self contained app, when nuget tries to pack core dll references throws the error 'The DateTimeOffset specified cannot be converted into a Zip file timestamp'
gci -path "$solutionPath\Output\Release" -rec -file *.dll | Where-Object {$_.LastWriteTime -lt (Get-Date).AddYears(-20)} | % { try { $_.LastWriteTime = '01/01/2000 00:00:00' } catch {} }
$csproj = Join-Path "$p" "Flow.Launcher/Flow.Launcher.csproj" -Resolve
$profile = Join-Path "$p" "Flow.Launcher/Properties/PublishProfiles/NetCore3.1-SelfContained.pubxml" -Resolve
# we call dotnet publish on the main project.
# The other projects should have been built in Release at this point.
dotnet publish -c Release $csproj /p:PublishProfile=$profile
}
function Main {
@ -116,15 +119,12 @@ function Main {
if ($config -eq "Release"){
if(IsDotNetCoreAppSelfContainedPublishEvent) {
FixPublishLastWriteDateTimeError $p
}
Delete-Unused $p $config
Publish-Self-Contained $p
$o = "$p\Output\Packages"
Validate-Directory $o
# making version static as multiple versions can exist in the nuget folder and in the case a breaking change is introduced.
New-Alias Nuget $env:USERPROFILE\.nuget\packages\NuGet.CommandLine\5.4.0\tools\NuGet.exe -Force
Pack-Squirrel-Installer $p $v $o
$isInCI = $env:APPVEYOR

View file

@ -26,6 +26,8 @@ before_build:
build:
project: Flow.Launcher.sln
verbosity: minimal
after_build:
- ps: .\Scripts\post_build.ps1
artifacts:
- path: 'Output\Packages\Flow-Launcher-*.zip'