"dotnet build" fails on non-Windows for projects that multi-target where Desktop is one of the targets frameworks.
See original GitHub issueIssue
If you have a project that multi-targets where one of Desktop is one of the target frameworks (such as <TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
), then the project will fail to build on non-windows with an error similar to:
Microsoft.Common.CurrentVersion.targets(1110,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Expected Result
The Desktop framework should be ignored and a warning should be printed indicated the framework in question could not be built.
This is a reasonable solution since the Desktop framework is not to be available on non-Windows.
Additional Details
This also impacts solutions where some projects target Desktop and some target .NETStandard or .NETCore and projects that only target Desktop.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:30
- Comments:19 (10 by maintainers)
Top Results From Across the Web
NETSDK1138: The target framework is out of support
In this article ... NETSDK1138 indicates that your project targets a version of the framework that is out of support. The full error...
Read more >Assets file obj\project.assets.json doesn't have a target
NET Standard and .NET Core when you're doing multi-targeting. You can't have a library target .NET Standard and then use dotnet build -f ......
Read more >Troubleshoot .NET Framework targeting errors
To resolve the error, make sure that your application targets a .NET version that's compatible with the version that's targeted by the projects...
Read more >NETSDK1100: Set the `EnableWindowsTargeting` property ...
To build a project targeting Windows on this operating system, set the EnableWindowsTargeting property to true. To resolve this error, set the ...
Read more >Multi-targetting .Net Framework and .Net Core in a single project
(Optional) Support building the netframework target on mono for linux or macos. In my case working on a Mac, my next error is....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@piotrpMSFT, that works for singular projects. That does not work when targeting an entire solution (which is perhaps a separate issue) where not every project targets the desired framework.
The command will fail with
project.assets.json' doesn't have a target for '.NETStandard,Version=v1.6'. Ensure you have restored this project for TargetFramework='netstandard1.6' and RuntimeIdentifier=''.
(or equivalent for whatever framework you built for).The workaround would be to build all
netstandard
projects first, then to build allnetcore
ornet
projects, but that quickly becomes untenable.ReferenceAssemblies are available on nuget.org now. You can add it like this:
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0-preview.2" PrivateAssets="All" />
With that you don’t need to hack paths for the Mono ReferenceAssemblies: