gpt4 book ai didi

msbuild - 带有 netstandard2.0 引用的 .net 4.8 项目将不会通过 msbuild 构建

转载 作者:行者123 更新时间:2023-12-04 17:25:36 29 4
gpt4 key购买 nike

该解决方案在 VS2019 中构建良好,但是当我们构建代理上的 msbuild 获得我们的解决方案时,它提示对我们的几个 dll 的引用。
我刚刚添加了对引入 netstandard 2.0 依赖项的 NuGet 包的引用,所以这似乎是问题所在。
我注意到,如果我进入构建服务器并在 VS FIRST 中构建解决方案......然后相同的 msbuild 命令行将在之后成功。因此,在正常构建情况下,这些网络标准 dll 的构建似乎确实如此,以便它们可以包含在其他项目编译中。

F:\Agents\MyAgent_work\18\s\src\WS_Reports.metaproj : warning MSB3268: The primary reference "F:\Agents\MyAgent_work\18\b\My.Project\My.Project.dll" could not be resolved because it has an indirect dependency on the framework assembly "netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.8". To resolve this problem, either remove the reference "F:\Agents\MyAgent_work\18\b\My.Project\My.Project.dll" or retarget your application to a framework version which contains "netstandard, Version=2.0.0.0, Culture=neutral, 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?

最佳答案

在您的 web.config 文件中,添加对 netstandard 程序集的引用:

<system.web>
<compilation debug="true" targetFramework="4.8">
<assemblies>
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.8" />
...

关于msbuild - 带有 netstandard2.0 引用的 .net 4.8 项目将不会通过 msbuild 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63712952/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com