question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multi framework targetting not working with VS2017 RC

See original GitHub issue

Steps 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 with netcoreapp1.0;net452, as demonstrated in this .NET Blog post under the section Cross-targeting.

Expected behavior

  • Project compiles for both netcoreapp1.0 and net452 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
MartinJohnscommented, Jan 20, 2017

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.

3reactions
nguerreracommented, Dec 12, 2016

@MartinJohns

The original issue was definitely using TargetFramework to specify multiple frameworks instead of TargetFrameworks (plural). The blog post has that right.

There are two other issues:

  1. 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

  2. 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:

    One or more packages are incompatible with .NETFramework,Version=v4.5.2.
    Package Microsoft.NETCore.App 1.0.1 is not compatible with net452 (.NETFramework,Version=v4.5.2).

For (1), here is how the main property group should look with both RuntimeIdentifer and TargetFrameworks set:

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>netcoreapp1.0;net452</TargetFrameworks>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
  </PropertyGroup>

For (2), here is how the NETCore.App package ref should be conditioned

  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
    <PackageReference Include="Microsoft.NETCore.App">
      <Version>1.0.1</Version>
    </PackageReference>
  </ItemGroup>

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found