MSBuild 不在 Bin 目录中创建 DLL

问题描述

我们在内部使用 ADO 2019,我们有一个构建服务器,我们可以在其中构建所有内容我有一个 ASPNet 网页,开发人员已将第二个项目添加到 SLN 进行测试。
我收到以下错误

XYZ.Tests\Properties\PexAssemblyInfo.cs(15,12): Error CS0246: The type or namespace name 'PexAssemblySettingsAttribute' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(15,12): Error CS0246: The type or namespace name 'PexAssemblySettings' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(18,12): Error CS0246: The type or namespace name 'PexAssemblyUnderTestAttribute' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(18,12): Error CS0246: The type or namespace name 'PexAssemblyUnderTest' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(19,12): Error CS0246: The type or namespace name 'PexInstrumentAssemblyAttribute' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(19,12): Error CS0246: The type or namespace name 'PexInstrumentAssembly' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(20,12): Error CS0246: The type or namespace name 'PexInstrumentAssemblyAttribute' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(20,12): Error CS0246: The type or namespace name 'PexInstrumentAssembly' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(21,12): Error CS0246: The type or namespace name 'PexInstrumentAssemblyAttribute' Could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\Properties\PexAssemblyInfo.cs(21,12): Error CS0246: The type or namespace name 'PexInstrumentAssembly' Could not be found (are you missing a using directive or an assembly reference?)

主项目在 Bin 目录中有所需的 Dll,但第二个项目在 Bin 目录中没有文件

我的 MSBuild 参数如下

/p:DeployOnBuild=true /p:WebPublishMethod=FileSy@R_404_6063@ /p:PrecompileBeforePublish=true 
/p:DeployDefaultTarget=WebPublish 
/p:publishUrl="$(build.artifactstagingdirectory)\$(BuildConfiguration)\wwwroot"  
/p:OutDir="\Bin\$(BuildConfiguration)"

我曾尝试使用 .csproj 预构建测试应用程序,但由于它没有自己的 SLN 失败。
所有 Nuget 包都在 Packages 目录中,但我继续收到这些错误。我就是不知道它从哪里想要什么。

解决方法

进行新更改后,您是否尝试在本地计算机上的 Visual Studio 中构建和测试项目?是否出现同样的错误?

该错误一般是由于未找到程序中使用的类型或命名空间造成的。您可能忘记引用包含该类型的程序集,或者您可能没有添加所需的 using 指令。或者,您尝试引用的程序集可能存在问题。有关更多详细信息,请参阅“Compiler Error CS0246”。

您可以在本地机器上的 Visual Studio 中尝试以下步骤,看看是否可以解决错误:

  1. 更正命名空间的名称。您可以使用下拉菜单“Intellisense”,也称为“自动完成”。

  2. 修复创建的自定义命名空间。

以下是类似问题的几张票作为参考。

[更新]

如果 DLL 是您的一些自定义或私有引用,要在 Azure DevOps 上的 Azure Pipelines 中构建项目时使用这些 DLL,我建议您可以将这些 DLL 作为包发布到 Azure Artifacts。如果您有 DLL 的任何代码更新,您还可以构建包的新版本并将其发布到 Azure Artifacts

将 DLL 作为包发布到 Azure Artifacts 后,在管道中构建项目时,您可以使用相关任务或命令将包恢复到项目源目录下的指定路径供使用。

就您而言,也许您可​​以尝试将这些 DLL 发布为 NuGet package