我应该改变什么,以便我可以在同一台机器上安装应用程序的 QA 和 Prod 版本?
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
# Build defintion variables to define:
# AgentPool = BUILD2_CD
# Env1 = Dev or UAT
# Env2 = QA or PROD
# BuildVersion = 1.0.0.1 , example
trigger:
- none
pool:
#name: BUILD2
name: $(AgentPool)
demands:
- npm
- msbuild
- visualstudio
- vstest
- DotNetFramework
variables:
BuildPlatform: 'x64'
BuildConfiguration: 'release'
major: 2
minor: 0
build: 0
revision: $[counter('rev', 0)]
BuildOutputFolder: 'Runtime'
isDevelop: $[eq(variables['Env1'], 'DEV')] # runtime expression
CertExportDir: '$(Build.ArtifactStagingDirectory)\AppxPackages\$(MsixPackageRootFolderName)'
CertFilePath: '$(Build.ArtifactStagingDirectory)\AppxPackages\$(MsixPackageRootFolderName)\PIE21stMortgage.pfx'
MsixPackageRootFolderName: 'DotnetCoreInstaller_$(BuildVersion)_$(BuildPlatform)_Test'
jobs:
- job: Phase1
displayName: "Client DotnetCore Installer "
timeoutInMinutes: 50
strategy:
maxParallel: 2
matrix:
ENV_1:
Multiplier: $(Env1)
ENV_2:
Multiplier: $(Env2)
steps:
- task: PowerShell@2
displayName: 'REST API : Update Build Version '
inputs:
targetType: filePath
filePath: ./Automation/RestApi/RestApiVersionCounter.ps1
continueOnError: true
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- task: PowerShell@1
displayName: 'PowerShell Script - Update ApplicationRevision '
inputs:
scriptType: inlineScript
inlineScript: |
$fileVersion = $Env:BuildVersion.Split(".")
$last3Numbers = [int]$fileVersion[3].ToString()
$path = "$(Build.SourcesDirectory)/DotnetCore/DotnetCore.csproj"
$word = "<ApplicationRevision>.*$"
$replacement = "<ApplicationRevision>" + $last3Numbers + "</ApplicationRevision>"
$text = get-content $path
$newText = $text -replace $word,$replacement
$newText > $path
(Get-Content $path) | Out-File -encoding UTF8 $path
- task: PowerShell@1
displayName: 'PowerShell Script - Update ApplicationVersion'
inputs:
scriptType: inlineScript
inlineScript: |
$path = "$(Build.SourcesDirectory)/DotnetCore/DotnetCore.csproj"
$word = "<ApplicationVersion>.*$"
$replacement = "<ApplicationVersion>" + $Env:BuildVersion + "</ApplicationVersion>"
$text = get-content $path
$newText = $text -replace $word,$replacement
$newText > $path
(Get-Content $path) | Out-File -encoding UTF8 $path
- task: PowerShell@1
displayName: 'PowerShell Script - Set BuildOutputFolder variable'
inputs:
scriptType: inlineScript
inlineScript: |
switch ($env:Multiplier) {
"PROD" {
$folderName = "Release"
}
"UAT" {
$folderName = "UATRelease"
}
"DEV" {
$folderName = "Debug"
}
"QA" {
$folderName = "QARelease"
}
}
Write-Host "Setting 'BuildOutputFolder' variable to: $folderName" -Verbose
Write-Host ("##vso[task.setvariable variable=BuildOutputFolder;]$folderName") -Verbose
- task: FileTransform@1
displayName: 'File Transform: App.config'
inputs:
folderPath: DotnetCoreFolder
enableXmlTransform: true
xmlTransformationRules: -transform **\App.$(BuildOutputFolder).config -xml **\App.config
fileType: xml
- powershell: |
# Update appxmanifest. This must be done before the build.
[xml]$manifest= get-content ".\DotnetCoreInstaller\Package.appxmanifest"
# $manifest.Package.Identity.Version = "$(major).$(minor).$(build).$(revision)"
$manifest.Package.Identity.Version = "$(BuildVersion)"
$manifest.Package.Applications.Application.VisualElements.DisplayName = "DotnetCore.$(Multiplier)"
$manifest.save("DotnetCoreInstaller/Package.appxmanifest")
displayName: 'Version Package Manifest'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '.\DotnetCore\DotnetCore.csproj'
- task: CopyFiles@1
displayName: 'Copy PIE21stMortgage.pfx File to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: D:\versions\CERT
Contents: PIE21stMortgage.pfx
TargetFolder: $(CertExportDir)
- task: MSBuild@1
inputs:
solution: DotnetCoreInstaller/DotnetCoreInstaller.wapproj
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: '/p:OutputPath=NonPackagedApp
/p:UapAppxPackageBuildMode=SideLoadOnly
/p:AppxBundle=Never
/p:GenerateAppInstallerFile=True
/p:AppInstallerUri=\\shares\Intranet\$(Multiplier)\DotnetCore
/p:AppInstallerCheckForUpdateFrequency=OnApplicationRun
/p:AppInstallerUpdateFrequency=1
/p:AppxPackageOutput=$(Build.ArtifactStagingDirectory)\DesktopApp.msix
/p:AppxPackageSigningEnabled=false
/p:PublishAssemblyName=$(Multiplier)
/p:ProductName=$(Multiplier)'
displayName: 'Package the App'
- script: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\signtool"
sign /fd SHA256 /f $(CertExportDir)/$(CertName) /p "$(CertPassword)" $(Build.ArtifactStagingDirectory)\DesktopApp.msix'
displayName: 'Sign MSIX Package'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: MSIX Package'
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)
ArtifactName: ClientDotnetCoreInstaller$(Multiplier)
- task: CopyFiles@1
inputs:
SourceFolder: '$(Build.ArtifactStagingDirectory)'
Contents: '**'
TargetFolder: '\\shares\Intranet\$(Multiplier)\DotnetCore'
OverWrite: true
- task: DeleteFiles@1
displayName: 'Delete PIE21stMortgage.pfx'
inputs:
SourceFolder: '\\21stmortgage\shares\Intranet\$(Multiplier)\DotnetCore\AppxPackages\$(MsixPackageRootFolderName)'
Contents: 'PIE21stMortgage.pfx'
- task: DeleteFiles@1
displayName: 'Delete files from $(Build.SourcesDirectory) '
condition: always()
continueOnError: True
enabled: False
inputs:
SourceFolder: $(Build.SourcesDirectory)
Contents: '\*'