Reputation: 1524
The solution builds fine in VS2019, but when msbuild on our build agents gets a hold of our solution its complaining about references to several of our dlls.
I've just added a reference to a NuGet package that brought in a netstandard 2.0 dependency, so that seems to be the problem.
I have noticed that if I go onto a build server and build the solution in VS FIRST....then the same msbuild command line will succeed afterwards. So it does seem to be the case that in the normal build situation these netstandard dlls arent being built such that they can be included in the other project compilations.
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".
Here's the solution file's declaration of the project whose msbuild throws the error....can see the project reference to the dlls that show up in the error (example above). Note that both this and the project I added my new netstandard2.0 packages to target framework 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
Perhaps I need the project throwing the errors OR the project(s) with the netstandard references to target both v4.8 and netstandard2.0?
Upvotes: 6
Views: 3517
Reputation: 836
In my case it was that the version of nuget was too old. When I used a newer version of nuget.exe for the restore the build via msbuild worked just fine.
Upvotes: 1
Reputation: 100581
In your web.config file, add a reference to the netstandard assembly:
<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" />
...
Upvotes: 3