.NET Framework 4.7.2 Service Fabric项目Azure DevOps构建失败求助
本地构建目标框架为.NET Framework 4.7.2的Service Fabric项目正常,Swagger页面也能加载,但Azure DevOps构建时抛出以下错误:
BaseOutputPath/OutputPath property is not set for project 'Test.sfproj'.
Please check to make sure that you have specified a valid
combination of Configuration and Platform for this project.
Configuration='Release'
Platform='x64'.You may be seeing this message because you are trying to build
a project without a solution file, and have specified a non-default
Configuration or Platform that doesn't exist for this project.
解决办法如下:
检查sfproj文件的配置平台映射
打开Test.sfproj,确认是否存在Release|x64的配置节。如果没有,手动添加以下XML节点:<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> <OutputPath>bin\Release\</OutputPath> <BaseOutputPath>bin\</BaseOutputPath> <PlatformTarget>x64</PlatformTarget> </PropertyGroup>确保Azure DevOps构建任务使用解决方案而非单独项目
在Azure DevOps构建管道中,不要直接指定构建Test.sfproj,选择对应的.sln解决方案文件,让MSBuild自动处理配置和平台的映射关系。验证构建任务的配置参数
在Azure DevOps的MSBuild任务里,确认Configuration参数设为Release,Platform参数设为x64,且这两个配置在解决方案中已经正确定义(可通过Visual Studio的解决方案属性查看)。检查解决方案的平台配置
在Visual Studio中打开解决方案,右键选"属性" -> "配置属性",确保Test.sfproj在Release|x64配置下的"生成"选项已勾选,且输出路径设置正确。
内容的提问来源于stack exchange,提问作者tarun susarapu

