我们从 Azure Pipelines (YAML) 开始,在 FileTransform 任务期间遇到以下错误:
##[error]Unable to apply transformation for the given package - Changes are already present in the package.
结果是没有发生任何转换,并且部署的配置与 Release.config 匹配
这是一个带有 Web.Config、Web.Stage.config、Web.Release.config 等的 ASP.NET Web 应用程序。
最终目标是设置不同的阶段并使用配置文件应用相应的转换。但现在,我只想获得“发布”版本并应用“阶段”转换,以确保此任务有效。
如果有帮助,这是 YAML 的一个片段:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
...
task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
...
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- task: FileTransform@2
inputs:
folderPath: '$(Build.ArtifactStagingDirectory)/**/*.zip'
xmlTransformationRules: '-transform **\*.Stage.config -xml **\*.config'
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'Microsoft Partner Network(blablabla)'
appType: 'webApp'
WebAppName: 'mywebapp'
packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
更新:最终的 web.config 文件包含如下连接字符串:
<add name="DefaultConnection" connectionString="$(ReplacableToken_DefaultConnection-Web.config Connection String_0)" providerName="System.Data.SqlClient"/>
这是构建步骤的日志。您可以看到在构建过程中发生了转换。
谢谢!
