Web.config 发布转换未作为 Azure DevOps 服务器中 Web 应用程序构建的一部分进行应用

Jas*_*win 5 asp.net msbuild continuous-integration azure-devops

我有一个 ASP.Net 框架 (v4.7) Web 应用程序,我在 Azure Devops Server (2019) 中有一个构建管道。

\n\n

有一个 Visual Studio 构建任务可以很好地构建解决方案并将站点发布到文件_PublishedWebsites夹。问题是,该版本的 web.config 转换尚未应用,但它仍然已debug="true"设置,这不是我想要的自动化部署。

\n\n

该任务的 msbuild 参数为:/p:outdir="$(build.artifactstagingdirectory)"且构建的 BuildConfiguration 变量设置为release

\n\n

当我使用 Visual Studio 发布项目时,将应用 web.release.config 转换,并且调试属性已从已发布内容的 web.config 文件中删除。

\n\n

我在这里缺少什么吗?

\n\n

编辑:构建管道 YAML:

\n\n
queue:\n  name: Default\n  demands: \n  - msbuild\n  - visualstudio\n\n#Your build pipeline references an undefined variable named \xe2\x80\x98Parameters.solution\xe2\x80\x99. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972\n#Your build pipeline references an undefined variable named \xe2\x80\x98Parameters.solution\xe2\x80\x99. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972\n#Your build pipeline references the \xe2\x80\x98BuildPlatform\xe2\x80\x99 variable, which you\xe2\x80\x99ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971\n#Your build pipeline references the \xe2\x80\x98BuildConfiguration\xe2\x80\x99 variable, which you\xe2\x80\x99ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971\n#Your build pipeline references the \xe2\x80\x98BuildPlatform\xe2\x80\x99 variable, which you\xe2\x80\x99ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971\n#Your build pipeline references the \xe2\x80\x98BuildConfiguration\xe2\x80\x99 variable, which you\xe2\x80\x99ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971\n#Your build pipeline references an undefined variable named \xe2\x80\x98Parameters.ArtifactName\xe2\x80\x99. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972\nsteps:\n- task: NuGetCommand@2\n  displayName: \'NuGet restore\'\n  inputs:\n    restoreSolution: \'$(Parameters.solution)\'\n\n\n- task: VSBuild@1\n  displayName: \'Build solution\'\n  inputs:\n    solution: \'$(Parameters.solution)\'\n\n    vsVersion: 16.0\n\n    msbuildArgs: \'/p:outdir="$(build.artifactstagingdirectory)"\'\n\n    platform: \'$(BuildPlatform)\'\n\n    configuration: \'$(BuildConfiguration)\'\n\n\n- task: VisualStudioTestPlatformInstaller@1\n  displayName: \'Visual Studio Test Platform Installer\'\n  inputs:\n    versionSelector: latestStable\n\n\n- task: VSTest@2\n  displayName: \'Test Assemblies\'\n  inputs:\n    testAssemblyVer2: |\n     $(build.artifactstagingdirectory)\\*test*.dll\n     !**\\obj\\**\n\n    vsTestVersion: toolsInstaller\n\n    platform: \'$(BuildPlatform)\'\n\n    configuration: \'$(BuildConfiguration)\'\n\n\n- task: PublishSymbols@2\n  displayName: \'Publish symbols path\'\n  inputs:\n    SearchPattern: \'**\\bin\\**\\*.pdb\'\n\n    PublishSymbols: false\n\n  continueOnError: true\n\n- script: |\n   cd ProjectName.Web.CMS\n   copy cmsimport.lic bin /y\n  displayName: \'Copy CMSImport licence to bin folder\'\n\n- script: |\n   ECHO Copying over the umbraco, umbraco_client and CMSImport content for deployment.\n\n   xcopy ProjectName.Web.CMS\\packages\\UmbracoCms.7.5.14\\UmbracoFiles\\umbraco $(build.artifactstagingdirectory)\\_PublishedWebsites\\ProjectName.Web.CMS\\umbraco\\ /s /e /r /y\n   xcopy "ProjectName.Web.CMS\\packages\\UmbracoCms.7.5.14\\UmbracoFiles\\umbraco_client" $(build.artifactstagingdirectory)\\_PublishedWebsites\\ProjectName.Web.CMS\\umbraco_client\\ /s /e /r /y\n   xcopy ProjectName.Web.CMS\\packages\\CMSImport.3.5\\content\\umbraco $(build.artifactstagingdirectory)\\_PublishedWebsites\\ProjectName.Web.CMS\\umbraco\\ /s /e /r /y\n  displayName: \'Copy umbraco related content to staging\'\n  enabled: false\n\n- script: |\n   cd ProjectName.Web.CMS\n   move robots_UAT.txt $(build.artifactstagingdirectory)\\_PublishedWebsites\\ProjectName.Web.CMS\\robots.txt\n  displayName: \'Add robots.txt file to artifacts staging directory\'\n\n- task: ArchiveFiles@2\n  displayName: \'Archive  $(build.artifactstagingdirectory)\\_PublishedWebsites\\ProjectName.Web.CMS\\\'\n  inputs:\n    rootFolderOrFile: \' $(build.artifactstagingdirectory)\\_PublishedWebsites\\ProjectName.Web.CMS\\\'\n\n    includeRootFolder: false\n\n    archiveFile: \'$(Build.ArtifactStagingDirectory)/ProjectName.Web.CMS.zip\'\n\n\n- task: PublishBuildArtifacts@1\n  displayName: \'Publish Artifact\'\n  inputs:\n    PathtoPublish: \'$(build.artifactstagingdirectory)\\ProjectName.Web.CMS.zip\'\n\n    ArtifactName: \'$(Parameters.ArtifactName)\'\n\n
Run Code Online (Sandbox Code Playgroud)\n

Jas*_*win 4

在将XDT 转换构建任务添加到我的 Azure DevOps 构建服务器后,我设法应用转换。

我做了一些阅读,表明作为 CI/CD 管道一部分的转换是作为 Azure 应用服务部署或 IIS 部署发布任务的一部分应用的,而不是由 msbuild 执行的。

也是一篇有趣的文章。遗憾的是,文件转换构建任务是预发布的,如果您在本地使用 Azure DevOps Server,则必须自己从源代码构建任务。我尝试过,但安装软件包后,任务并未显示为可添加。XDT 转换任务是一个很好的替代任务,并且做得很好。