Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2017RC3 - Portable class library in TargetFrameworks errors on build #1369

Closed
JamesNK opened this issue Jan 30, 2017 · 8 comments
Closed

Comments

@JamesNK
Copy link
Member

JamesNK commented Jan 30, 2017

I used the same format that I did in project.sjon:

<TargetFrameworks>net45;net40;net35;net20;netstandard1.0;.NETPortable,Version=v4.5,Profile=Profile259</TargetFrameworks>

Error:

MSB4086	A numeric comparison was attempted on "$(_TargetFrameworkVersionWithoutV)" that evaluates to "" instead of a number, in condition " '$(_TargetFrameworkVersionWithoutV)' >= '3.5' ".
@clairernovotny
Copy link
Member

You need to use the short TFM and use properties:

https://github.com/onovotny/Zeroconf/blob/dev/Zeroconf/Zeroconf.csproj#L32-L37

For PCL 259, the properties would be:

  <PropertyGroup Condition="'$(TargetFramework)' == 'portable-net45+win8+wpa81+wp8'">
    <TargetFrameworkIdentifier>.NETPortable</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
    <NugetTargetMoniker>.NETPortable,Version=v0.0,Profile=Profile259</NugetTargetMoniker>
    <LanguageTargets>$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets</LanguageTargets>
  </PropertyGroup>

@clairernovotny
Copy link
Member

clairernovotny commented Jan 30, 2017

Note that the Version=v0.0 bit is due to a bug and is being tracked here: dotnet/sdk#492

But the above should work for you.

Downside though -- requires Windows to build, not dotnet build. You need to run msbuild /t:restore then either msbuild /t:build or msbuild /t:pack to build and/or pack and build the project. That makes it use the desktop MSBuild, which is probably needed for the tasks that are in the Portable framework targets.

@JamesNK
Copy link
Member Author

JamesNK commented Jan 31, 2017

I have a PCL build working.

Will PCL ever work with dotnet build?

@srivatsn
Copy link
Contributor

https://github.com/dotnet/cli/issues/5504 tracks building non-.NET Core projects with the CLI.

Adding these propertygroups to the SDK so that this is supported OOB is tracked by dotnet/sdk#491

@JamesNK
Copy link
Member Author

JamesNK commented Feb 11, 2017

@onovotny How do you figure out where on disk msbuild for VS 15.0 is located? Is there a registry key with that information somewhere? I don't want to bake the path on my local computer into a build script.

@clairernovotny
Copy link
Member

clairernovotny commented Feb 11, 2017

There's no real path that I know of, but that's the value used in the new project templates. It's controlled by MSBuildExtensionsPath32, which is set by MSBuild.

Do file -> new portable class library then see what the imports statement is at the bottom.

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />

It's the location that all of the project templates use, so I have to assume it's safe to use that path elsewhere as well. Otherwise PCL projects won't load/build at all for VS :)

@clairernovotny
Copy link
Member

Doh, just re-read your question and totally missed it...need coffee!

https://github.com/Microsoft/vssetup.powershell

That's probably what you want; it'll show you the available instances of VS (and from there you can get the path to MSBuild from the top level folder).

@jnm2
Copy link

jnm2 commented Feb 11, 2017

See also dotnet/msbuild#1377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants