【发布时间】:2020-12-22 01:27:43
【问题描述】:
该解决方案在 VS2019 中构建良好,但是当我们的构建代理上的 msbuild 获取我们的解决方案时,它抱怨对我们的几个 dll 的引用。
我刚刚添加了对 NuGet 包的引用,该包引入了 netstandard 2.0 依赖项,所以这似乎是问题所在。
我注意到,如果我进入构建服务器并在 VS FIRST 中构建解决方案......然后相同的 msbuild 命令行将在之后成功。因此,在正常构建情况下,这些 netstandard dll 似乎并没有被构建,以便它们可以包含在其他项目编译中。
F:\Agents\MyAgent_work\18\s\src\WS_Reports.metaproj:警告 MSB3268:主要参考“F:\Agents\MyAgent_work\18\b\My.Project\My.Project.dll”不能因为它间接依赖于框架程序集“netstandard,Version=2.0.0.0,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”,在当前目标框架中无法解决。 “.NETFramework,版本=v4.8”。要解决此问题,请删除引用“F:\Agents\MyAgent_work\18\b\My.Project\My.Project.dll”或将您的应用程序重新定位到包含“netstandard, Version=2.0.0.0,文化=中性,PublicKeyToken=cc7b13ffcd2ddd51"。
这是解决方案文件对 msbuild 引发错误的项目的声明....可以看到项目对出现在错误中的 dll 的引用(上面的示例)。请注意,这个项目和我将新的 netstandard2.0 包添加到目标框架 v4.8 的项目
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WS.Reports", "WebServices\WS.Reports\", "{C47BAAE6-0708-4D43-83B8-92405B31A3E0}"
ProjectSection(WebsiteProperties) = preProject
SccProjectName = "SAK"
SccAuxPath = "SAK"
SccLocalPath = "SAK"
SccProvider = "SAK"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.8"
ProjectReferences = "{2222173A-112A-44F8-A614-C7CCBDACEFE8}|My.Project.Bus.dll;{222924FE-877B-4E18-B960-94DED3DB6DF2}|MyProject.Protocols.Shared.dll;{222F5846-55E6-4541-B43B-E49674963E02}|MyProject.AuthProtocols.dll;{2224BC03-6C7E-4E15-B158-D9BD03D0E8B3}|My.Project.dll;{222BAF47-1C9F-4A56-9152-B4240A188612}|My.Project.Images.dll;{222FE788-27B1-4B03-B052-BCFFF251C15A}|My.Project.Legacy.dll;"
Debug.AspNetCompiler.VirtualPath = "/WS.Reports"
Debug.AspNetCompiler.PhysicalPath = "WebServices\WS.Reports\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\WS.Reports\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/WS.Reports"
Release.AspNetCompiler.PhysicalPath = "WebServices\WS.Reports\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\WS.Reports\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
VWDPort = "17515"
VWDDynamicPort = "false"
SlnRelativePath = "WebServices\WS.Reports\"
StartServerOnDebug = "false"
EndProjectSection
EndProject
也许我需要抛出错误的项目或带有 netstandard 引用的项目以同时定位 v4.8 和 netstandard2.0?
【问题讨论】:
-
4.8 引用 netstandard2.0 应该没问题,不需要多目标。您只需要更新的 msbuild 版本吗?
-
感谢您对多目标的确认......这似乎不再有意义(4.7.2 及更高版本)。将检查 msbuild 版本。由于 4.8 项目(和其他一些 .netcore3.1)在此 netstandard 参考之前一直在工作,因此这似乎不太可能是错误的。 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe"
-
这个 github issue track 似乎是针对同样的问题。 github.com/dotnet/standard/issues/1771
-
@Bob 你遇到过这个吗?
标签: msbuild .net-standard