Multi framework targetting not working with VS2017 RC
See original GitHub issueSteps to reproduce
- Install Visual Studio 2017 RC with .NET Core support.
- Create a new .NET Core project. Type seemingly does not matter, tested with Web MVC and Console application.
- Right click on project in Solution Explorer and select “Edit name.csproj”
- Find the line with the
TargetFramework
element. - Replace
netcoreapp1.0
withnetcoreapp1.0;net452
, as demonstrated in this .NET Blog post under the section Cross-targeting.
Expected behavior
- Project compiles for both
netcoreapp1.0
andnet452
as previously with the project.json format.
Actual behavior
Error occurs:
MSB4115 The "HasTrailingSlash" function only accepts a scalar value, but its argument "$(OutputPath)" evaluates to "bin\Debug\netcoreapp1.0;net452\" which is not a scalar value.
Environment data
dotnet --info
output:
.NET Command Line Tools (1.0.0-preview3-004056)
Product Information:
Version: 1.0.0-preview3-004056
Commit SHA-1 hash: ccc4968bc3
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:18 (7 by maintainers)
Top Results From Across the Web
Problem with multi target frameworks in asp web site
I have developed a C# Library Framework that targets both .NetStandard & .NetFramework. This was done by editing the .csproj file, ...
Read more >Cross-targeting frameworks with NuGet 4.0 and Visual ...
I've gotten this to work on latest Visual Studio 2017. As described in this post ... Cross-target multiple target frameworks in one project....
Read more >Targeted .NET Frameworks - Visual Studio (Windows)
You can target multiple frameworks in a single project. ... Framework targeting does not guarantee that your application will run correctly.
Read more >Msbuild not found. This is due to your VCTargetsPath path ...
Msbuild not found. This is due to your VCTargetsPath path variable … 08/05/2021 1 contributor Feedback This error occurs when an MSBuild project...
Read more >Multi framework targetting not working with VS2017 RC
Install Visual Studio 2017 RC with .NET Core support. · Create a new .NET Core project. · Right click on project in Solution...
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 Free
Top 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
My suggestion is to remove the distinction. Why have two element names for a single purpose? It just adds unnecessary complexity. The new format is supposed to be simplified.
@MartinJohns
The original issue was definitely using
TargetFramework
to specify multiple frameworks instead ofTargetFrameworks
(plural). The blog post has that right.There are two other issues:
Currently, you do need to specify a RuntimeIdentifier if one of your targets is the full .NET Framework and you are building an exe. We are looking to improve this, see https://github.com/dotnet/sdk/issues/396
You must condition the .NETCoreApp package reference to only the netcoreapp1.0 build as the package is not compatible with net452. This is also being improved with https://github.com/dotnet/sdk/pull/450 which will make the package ref implicit and remove you from having to condition it yourself.
(1) above explains the RuntimeIdentifier error you’re seeing. (2) might be the “invalid restore input” you’re seeing, but I’m seeing much clearer nuget errors on newer than RC bits:
For (1), here is how the main property group should look with both RuntimeIdentifer and TargetFrameworks set:
For (2), here is how the NETCore.App package ref should be conditioned
Let me know if you’re still seeing errors after applying the above and please share the full .csproj that isn’t working for you.