2

I'm trying to figure out how to migrate a project from PCL to .netstandard 1.2.

I have a solution where I have a PCL project (portable45-net45+win8+wpa81) and a .Net Standard (netstandard1.2) project which has all it files linked into the PCL project.

Currently we create a nuget package from the PCL project using a nuspec file. Now what would be the best approach to have both available in 1 nuget package? I find the use of nuget pack vs dotnet pack and mixing multiple frameworks and project types (csproj) very confusing.

Also appearantly there is a new csproj format for VS2017+ projects, should I convert the PCL project?

Eventually the nuget should only contain the .netstandard1.2 project but we want to take both up the dependency tree during migration.

grmbl
  • 2,514
  • 4
  • 29
  • 54
  • You have to use the new csproj format in Vs2017 for a netstandard or multitargetted project. – pinkfloydx33 Jul 11 '18 at 07:08
  • what do you mean that `what would be the best approach to have both available in 1 nuget package?`? Do you mean you want include the PCL project and .Net Standard (netstandard1.2) project in to one nuget package? – Leo Liu Jul 11 '18 at 09:51
  • yes, that's what I'm trying to achieve, maybe it's better to create a single project and work with multiple TargetFrameWork? – grmbl Jul 11 '18 at 13:34
  • Is there a requirement to have both a PCL and a .NET Standard asset in the package? Have you considered converting your PCL library to .NET Standard 1.1 and only have that asset in the package? Based on [this](https://github.com/dotnet/standard/blob/master/docs/versions.md), a PCL profile 111 library could be converted to .NET Standard 1.1. – Alex Ghiondea - MSFT Jul 11 '18 at 21:52

1 Answers1

1

what would be the best approach to have both available in 1 nuget package?

You can still use .nuspec file to accomplish this, just need include the dll files from PCL project and .Net Standard project into different frameworks.

Following is my test .nuspec file, you can check it for details:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>My.Package</id>
    <version>1.0.0</version>
    <authors>Tester</authors>
    <owners>Tester</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2018</copyright>
    <tags>Tag1 Tag2</tags>
  </metadata>
    <files>
       <file src="TestPCL\bin\Debug\TestPCL.dll" target="lib\portable-net45+wp8\" />
       <file src="TestStandard\bin\Debug\netstandard1.2\TestStandard.dll" target="lib\netstandard1.2\" />
    </files>
</package>

When you install this package to the PCL project and .Net Standard project, nuget will select the DLL file under the corresponding framework to your project.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135