yaml - MsBuild 在目标发布多个文件夹而不使用输入参数
问题描述
我正在将 WPS 应用程序部署到多个不同的共享网络驱动器。每个应用程序都必须针对不同的数据库。最重要的是,由于我使用的是 clickOnce 部署,因此每个位置都需要自己的 PublishUrl 和 InstallUrl。
我目前有一个可以部署到每个位置的管道(最终我会将它分解为多个管道)。
问题是它发布时会创建两个文件夹。一个MyAppName
和另一个MyAppNameapp.publish
它没有设置InstallUrl
, PublishUrl
,UpdateUrl
或$(AssemblyVersion)
and (不知道是否是一个实际问题)将 deploymentProvider 代码库设置为我的本地代理内的一个文件夹(用于运行此管道)。
Folder:MyAppName
Contains
A published version of my application
Folder:MyAppNameapp.publish
Contains
Setup.exe
MyAppName.application
Inside File
<deploymentProvider codebase="[Folder inside my local agent]" />
Missing InstallUrl, PublishUrl, UpdateUrl
MyAppName.exe
Folder:Application Files
Contains
Folder:MyAppNameapp_$(AssemblyVersion)
Contains
A published version of my application
如何将 MsBuild 限制为仅创建MyAppNameapp.publish
(但重命名为MyAppName
)
这是用于创建这些文件夹的 MsBuild 任务。
- task: MSBuild@1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '/target:Publish
/p:ApplicationVersion=$(AssemblyVersion)
/p:UpdateEnabled=true /p:UpdateMode=Foreground
/p:ProductName=TenantAnalyticsTool
/p:InstallUrl=c:\sandbox\deploytesting\siteA
/p:PublishUrl=c:\sandbox\deploytesting\siteA
/p:UpdateUrl=c:\sandbox\deploytesting\siteA
/p:OutputPath=c:\sandbox\deploytesting\siteA
/p:OutDir=c:\sandbox\deploytesting\siteA '
msbuildArchitecture: x64
我试过了:
- 将 OutputPath 和 OutDir 重定向到不同的位置,但在c:\sandbox\deploytesting\siteA
.
- 删除两者会导致不创建文件夹。如果我只删除一个(任何一个)MSBuild 不会复制所有文件。
完成 yaml
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool: Default
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: MSBuild@1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArchitecture: 'x64'
- task: VisualStudioTestPlatformInstaller@1
inputs:
packageFeedSelector: 'nugetOrg'
versionSelector: 'latestStable'
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
vsTestVersion: 'toolsInstaller'
- task: MSBuild@1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '/target:Publish
/p:ApplicationVersion=$(AssemblyVersion)
/p:UpdateEnabled=true /p:UpdateMode=Foreground
/p:ProductName=TenantAnalyticsTool
/p:InstallUrl=c:\sandbox\deploytesting\siteA
/p:PublishUrl=c:\sandbox\deploytesting\siteA
/p:UpdateUrl=c:\sandbox\deploytesting\siteA
/p:OutputPath=c:\sandbox\deploytesting\siteA
/p:OutDir=c:\sandbox\deploytesting\siteA '
msbuildArchitecture: x64
新的 MSBuild@1 测试。
- task: MSBuild@1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '/t:Publish
/p:ApplicationVersion=$(Build.BuildId)
/p:UpdateEnabled=true
/p:UpdateMode=Foreground
/p:ProductName=TenantAnalyticsTool
/p:OutputPath=c:\sandbox\deploytesting\siteC
/p:InstallUrl=c:\sandbox\deploytesting\siteC
/p:PublishUrl=c:\sandbox\deploytesting\siteC'
msbuildArchitecture: x64
结果:文件夹结构保持不变
MyAppName.application 内部
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<assemblyIdentity name="MyAppName" version="1.0.0.34" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="CBRE" asmv2:product="Tenant Tool Analytics Module" xmlns="urn:schemas-microsoft-com:asm.v1" />
<deployment install="true" co.v1:createDesktopShortcut="true">
<subscription>
<update>
<beforeApplicationStartup />
</update>
</subscription>
<deploymentProvider codebase="file://catd...[Not a location specified in the pipe].../MyAppName.application" />
</deployment>
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
<framework targetVersion="4.7.2" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>
<dependency>
<dependentAssembly dependencyType="install" codebase="Application Files\Tenant Tool Analytics Module_198\Tenant Tool Analytics Module.exe.manifest" size="8606">
<assemblyIdentity name="Tenant Tool Analytics Module.exe" version="1.0.0.34" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>R5zudfS3VXtM5dKoEFbHYoZih0Sxr8CjX33H5FgvBk8=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
</asmv1:assembly>
解决方案
/t:Publish
将发布到 Property 中定义的文件夹 /p:OutputPath=siteA
。并且将创建一个子文件夹发布。所以这个例子将发布到文件夹siteA\publish
/p:OutDir
是为/t:build
。它将包含构建结果中的文件。
对于你的情况,我认为你只能使用/p:OutputPath
,而不是/p:OutDir
。
至于$(AssemblyVersion)
没有设置。这是因为 AssemblyVersion 未在您的管道变量中定义。管道中的语法$()
将查找管道中定义的variables
变量或管道预定义的变量。
推荐阅读
- c# - 创建时隐藏的表单不接收广播消息
- angular6 - Angular 6 - 如何从使用 *ngFor 的表中动态创建的输入框中获取 component.ts 中的输入值?
- machine-learning - 机器学习标称数据
- php - 函数执行时间在 PHP 中第二次减少了很多
- mongodb - mongoDB复制故障转移不会自动从辅助更改为主
- java - Android Mux mp4a 和 mp4
- python - python-poppler-qt5 的构建轮失败
- python-2.7 - 处理大量行(熊猫数据框)以按条件过滤行
- python - 如何在散景图像图中更改颜色映射器
- docker - 保存 Dockerfile ENV 变量以供将来使用