如何解决构建多目标解决方案导致未找到类型或命名空间错误
我正在 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
我没有想法,我应该考虑什么来解决这个问题?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。