Version Used:
VS 2015 Update 3
Steps to Reproduce:
Expected Behavior:
Build succeeds without error
Actual Behavior:
Build fails with
| Severity | Code | Description | Project | File | Line | Suppression State |
| --- | --- | --- | --- | --- | --- | --- |
| Error | | Your project is not referencing the ".NETPlatform,Version=v5.0" framework. Add a reference to ".NETPlatform,Version=v5.0" in the "frameworks" section of your project.json, and then re-run NuGet restore. | ClassLibrary3 | C:\Program Files (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.targets | 140 | |
As @akoeplinger pointed out here https://github.com/dotnet/corefx/issues/10213#issuecomment-235049724 this is due to missing entries in C:\Program Files (x86)\MSBuild\Microsoft\Portable\v5.0\Microsoft.Portable.Common.targets
.
Not sure if roslyn is the right repo for PCL bugs but its the only one I'm aware of that is tracked by the folks that own this component.
/cc @rchande @Pilchie
We'll need to figure out what the plan is here for VS "15" PCLs versus .NET Core Class Libraries. In the meantime, there is a workaround of explicitly specifying something in your .csproj.
@Pilchie, how do I "explicitly specify something" in my .csproj? Could you please explain what you mean? I'm trying to build a class library for .NET Core using MSBuild and making a PCL targeting netstandard1.6 seems a good way to me. Or is there a better way?
@prochan2 Try adding <NuGetTargetMoniker>.NETStandard,Version=v1.6</NuGetTargetMoniker>
to the <PropertyGroup>
at the top of your .csproj file.
You need to do it after the last import statement since PCL overwrites the value of this property.
It works, thanks @Pilchie & @ericstj!
The workaround doesn't seem to work for me when running from a TFS (xaml) build. Neither does updating the Microsoft.Portable.Common.targets
.
Same thing as @sickboy . Building through VS 2015 works perfectly, but using MSBuild fails.
You added something here for RC, right?
Fixed in RC2.
I have this issue today in VS 2015 Update 3 with a PCL targetting .NETStandard1.6
I tried the workaround but no difference, I do not understand @ericstj "You need to do it after the last import statement since PCL overwrites the value of this property." becuase all my PropertyGroup elements are way above my last Import element - which is near the bottom.
OK I moved my bottom Import element to above PropertyGroup, now when VS reloads project it is unavailable and I get a context menu option on right-click to install update.. doing that now..
(This versioning of .NET Core, PCL's and UWP is a really pain the arse no doubt hurting any uptake of this new tech).
Installer says nothing new to install.. Screw it im just going to add common files as link instead try use library.
I added
<PropertyGroup>
<NuGetTargetMoniker>.NETStandard,Version=v1.6</NuGetTargetMoniker>
</PropertyGroup>
at the end of my csproj, before the and after the comment about adding tasks, w/ VS2015.3 and targeting netstandard1.6. It finally compiled for me w/ VS.
Just lost 20+ mins having this exact same issue. @ryanlederman's comment gave _exactly_ what was needed to resolve. Thanks!
PS: Current tooling is:
Easily reproducible given the steps in the Issue. :+1:
The build is successful but I got lots of warnings. Should they just be ignored?
Package Microsoft.NETCore.Portable.Compatibility 1.0.1 is not compatible with dotnet (.NETPlatform,Version=v5.0). Package Microsoft.NETCore.Portable.Compatibility 1.0.1 supports:
Most helpful comment
I added
<PropertyGroup> <NuGetTargetMoniker>.NETStandard,Version=v1.6</NuGetTargetMoniker> </PropertyGroup>
at the end of my csproj, before the and after the comment about adding tasks, w/ VS2015.3 and targeting netstandard1.6. It finally compiled for me w/ VS.