Azure Devops:在发布模式下构建多项目解决方案,但在调试中寻找缺少的程序集

时间:2019-07-04 02:13:02

标签: azure-devops continuous-integration

我正在尝试在Azure DevOps中构建多项目解决方案以部署到Azure。此解决方案可以在本地计算机上很好地构建,但是在Azure中出现以下构建错误。

##[error]TCGTools.net\Controllers\SettingsController.cs(8,7): Error CS0246: The type or namespace name 'TCGSniperCore' could not be found (are you missing a using directive or an assembly reference?)

TCGSniperCore是我的解决方案中的.netcore库。 MVC项目引用了该库。

浏览了完整的日志文件后,我发现该解决方案正在以发布模式构建.netcore库,但随后在调试文件夹中查找了.dll。

构建库时控制台输出:

CopyFilesToOutputDirectory: 
Copying file from "obj\Release\netcoreapp2.2\TCGSniperCore.dll" to 
"bin\Release\netcoreapp2.2\TCGSniperCore.dll".
TCGSniperCore -> 
D:\a\1\s\tcgsnipercore\bin\Release\netcoreapp2.2\TCGSniperCore.dll
Copying file from "obj\Release\netcoreapp2.2\TCGSniperCore.pdb" to 
"bin\Release\netco

在构建MVC项目时控制台输出:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "TCGSniperCore". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\a\1\s\TCGTools.net\TCGTools.net.csproj]
      For SearchPath "{HintPathFromItem}".
      Considered "..\tcgsnipercore\bin\Debug\netcoreapp2.2\TCGSniperCore.dll", but it didn't exist.
      For SearchPath "{RawFileName}".
      Considered treating "TCGSniperCore" as a file name, but it didn't exist.

我尝试了以下方法:

  1. 确保两个项目都以.netcore2.2为目标
  2. 在Azure DevOps中将代理程序池设置为托管VS2017
  3. 设置要释放的BuildConfiguration变量
  4. 在本机上复制。我不能。该解决方案构建良好。

为什么要在/ debug中而不是/ release中寻找程序集?

1 个答案:

答案 0 :(得分:0)

我发现它根据.csproj文件中指定的文件路径查找.dll。编辑文件(我使用VS Code),然后使用$(配置)添加/修改提示路径。

之前:

<ItemGroup> 
  <Reference Include="TCGSniperCore"> 
   <HintPath>..\tcgsnipercore\bin\Debug\netcoreapp2.2\TCGSniperCore.dll</HintPath> 
  </Reference>
</ItemGroup> 

之后:

<ItemGroup> 
  <Reference Include="TCGSniperCore"> 
   <HintPath>..\tcgsnipercore\bin\$(configuration)\netcoreapp2.2\TCGSniperCore.dll</HintPath> 
  </Reference>
</ItemGroup> 

感谢@ D.J。