构建多目标解决方案导致未找到类型或命名空间错误

我正在 Azure DevOps 中构建面向 4.7.2 和 5.0 的解决方案。解决方案有三个项目,其中一个依赖于另一个:

  • A - 取决于 B
  • B - 无依赖
  • C - 无依赖

项目 B 和 C 构建没有问题,但 A 抛出错误:

D:\a\1\s\MyFile.cs(12,24): error CS0246: The type or namespace name 'HttpContextBase' could not be found (are you missing a using directive or an assembly reference?) 
D:\a\1\s\MyFile.cs(10,10): error CS0246: The type or namespace name 'DescriptionAttribute' could not be found (are you missing a using directive or an assembly reference?)
D:\a\1\s\MyFile.cs(10,10): error CS0246: The type or namespace name 'Description' could not be found (are you missing a using directive or an assembly reference?)

项目B中文件相关的错误,已经成功构建。

这些引用绝对存在,该解决方案针对框架或核心在本地构建良好。我已经添加了对 csproj 的引用以包含 System.ComponentModel,但这并不能解决 Description 和 DescriptionAttribute 错误。同样,添加对 system.web 的引用也没有区别。我不希望这些引用是必需的,再次考虑到解决方案在本地正确构建,没有添加引用。

YML 看起来是这样的,这里没什么特别的,只是恢复并打包每个项目:

- task: DotNetCoreclI@2
  inputs:
    command: restore
    projects: $(Projects)
    selectOrConfig: config
    nugetconfigPath: NuGet.config
    verbosityRestore: Normal

- task: DotNetCoreclI@2
  inputs:
    command: pack
    projects: $(Projects)
    searchPatternPack: // paths to projects
    packDirectory: '$(OutDir)'
    includesymbols: true
    verbosityPack: Normal

我没有想法,我应该考虑什么来解决这个问题?

baojingxzwj 回答:构建多目标解决方案导致未找到类型或命名空间错误

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/5708.html

大家都在问