Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a self-contained standalone exe to our release for users without .NET installed #79

Merged
merged 24 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ Click on the individual commands to learn more.

You can use WingetCreate to update your existing app manifest as part of your CI/CD pipeline. For reference, see the final task in this repo's [release Azure pipeline](https://github.com/microsoft/winget-create/blob/main/pipelines/azure-pipelines.release.yml).

Unfortunately we can't use the msixbundle in a standard Azure Pipeline pool. Instead, use the standalone exe, the latest version of which can be found at https://aka.ms/wingetcreate/latest, and the latest preview version can be found at https://aka.ms/wingetcreate/preview. Note
that currently, the standalone exe requires .NET to be installed on the build machine.
Unfortunately we can't use the msixbundle in a standard Azure Pipeline pool. Instead, use the standalone exe, the latest version of which can be found at https://aka.ms/wingetcreate/latest, and the latest preview version can be found at https://aka.ms/wingetcreate/preview, both of these require .NET to be installed on the build machine.

If .NET isn't already installed, you can use https://aka.ms/wingetcreate/latest/self-contained or https://aka.ms/wingetcreate/preview/self-contained, which has .NET built-in, but is a larger download.

Then simply add a new powershell task to download the exe, and run it to update your manifest. It's recommended to not hardcode your PAT in your script, but instead use a [secret pipeline variable](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables)

Expand Down
39 changes: 30 additions & 9 deletions pipelines/azure-pipelines.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ jobs:
version: "$(majorMinorBuildVersion).$(revision)"
appxBundleFile: "Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle"
appxBundlePath: '$(appxPackageDir)\$(appxBundleFile)'
exePath: '$(appxPackageDir)\WingetCreateCLI\wingetcreate.exe'
exeDirSelfContained: '$(appxPackageDir)\selfcontained'
exeDirFrameworkDependent: '$(appxPackageDir)\dependent'
exePathSelfContained: '$(exeDirSelfContained)\WingetCreateCLI\wingetcreate-self-contained.exe'
exePathFrameworkDependent: '$(exeDirFrameworkDependent)\WingetCreateCLI\wingetcreate.exe'
pool:
vmImage: $(vmImageName)

Expand All @@ -56,7 +59,8 @@ jobs:
- powershell: |
echo $(version)
echo $(appxBundlePath)
echo $(exePath)
echo $(exePathSelfContained)
echo $(exePathFrameworkDependent)
echo "##vso[task.setvariable variable=manifestVersion;isOutput=true]$(version)"
name: OutputVersionStep
displayName: Display version and paths for diagnosing
Expand Down Expand Up @@ -99,13 +103,22 @@ jobs:
projects: $(workingDirectory)/**/*.csproj

- task: DotNetCoreCLI@2
displayName: Build standalone exe
displayName: Build standalone, framework-dependent exe
inputs:
command: publish
publishWebProjects: false
zipAfterPublish: false
projects: $(workingDirectory)/**/WingetCreateCLI.csproj
arguments: "--configuration Release --runtime=win-x64 --output $(appxPackageDir) -p:DebugType=None -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=false"
arguments: "--configuration Release --runtime=win-x64 --output $(exeDirFrameworkDependent) -p:DebugType=None -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=false"

- task: DotNetCoreCLI@2
displayName: Build standalone, self-contained exe
inputs:
command: publish
publishWebProjects: false
zipAfterPublish: false
projects: $(workingDirectory)/**/WingetCreateCLI.csproj
arguments: "--configuration Release --runtime=win-x64 --output $(exeDirSelfContained) -p:DebugType=None -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=true"

- task: MSBuild@1
displayName: Build Solution
Expand Down Expand Up @@ -152,8 +165,10 @@ jobs:
]

- powershell: |
ren "$(appxPackageDir)\WingetCreateCLI\WingetCreateCLI.exe" wingetcreate.exe
(Get-FileHash -Algorithm SHA256 -Path $(exePath)).Hash > "$(exePath).txt"
ren "$(exeDirFrameworkDependent)\WingetCreateCLI\WingetCreateCLI.exe" wingetcreate.exe
ren "$(exeDirSelfContained)\WingetCreateCLI\WingetCreateCLI.exe" wingetcreate-self-contained.exe
(Get-FileHash -Algorithm SHA256 -Path $(exePathFrameworkDependent)).Hash > "$(exePathFrameworkDependent).txt"
(Get-FileHash -Algorithm SHA256 -Path $(exePathSelfContained)).Hash > "$(exePathSelfContained).txt"
(Get-FileHash -Algorithm SHA256 -Path $(appxBundlePath)).Hash > "$(appxBundlePath).txt"
displayName: "Create hash files"

Expand All @@ -163,8 +178,10 @@ jobs:
targetFolder: $(Build.ArtifactStagingDirectory)
flattenFolders: true
contents: |
$(exePath)
$(exePath).txt
$(exePathFrameworkDependent)
$(exePathSelfContained)
$(exePathFrameworkDependent).txt
$(exePathSelfContained).txt
$(appxBundlePath)
$(appxBundlePath).txt

Expand Down Expand Up @@ -215,7 +232,11 @@ jobs:

# https://aka.ms/wingetcreate/latest points to latest version of wingetcreate.exe
# https://aka.ms/wingetcreate/preview points to latest preview version of wingetcreate.exe
# requires .NET to be installed on the build machine to operate correctly
# requires .NET to be installed on the build machine to operate correctly, but is a smaller download

# https://aka.ms/wingetcreate/latest/self-contained points to latest self-contained version of wingetcreate.exe
# https://aka.ms/wingetcreate/preview/self-contained points to latest self-contained preview version of wingetcreate.exe
# does not require .NET to be installed on the build machine to operate correctly, but is a larger download

iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
wingetcreate.exe update -i Microsoft.WingetCreate -u $(packageUrl) -v $(manifestVersion) -t $(GITHUB_PAT) --submit
Expand Down