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

Nuget Warning for canopy in .NET Core 2 Project #431

Open
totano opened this issue Apr 13, 2018 · 13 comments
Open

Nuget Warning for canopy in .NET Core 2 Project #431

totano opened this issue Apr 13, 2018 · 13 comments

Comments

@totano
Copy link

totano commented Apr 13, 2018

NU1701	
Package 'canopy 2.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
@lefthandedgoat
Copy link
Owner

Does it still work? I have googled around and after reading the first page I haven't figured out how to fix it.

@lefthandedgoat
Copy link
Owner

I made a new .net core app and can repro it, but im having a hard time figuring out what the do to fix it. I will try a few things

@totano
Copy link
Author

totano commented Apr 14, 2018

yes, it is just a warning

@netmajor
Copy link

netmajor commented May 2, 2018

Same here with Console Application (.NET Core 2.0):
"Package 'canopy 2.0.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project."

@zbigniew-gajewski
Copy link

I have made a small research and found that when canopy package is created with dotnet pack then adding package to another project shows no warnings (works correct).

What I did:

git clone https://github.com/lefthandedgoat/canopy.git
cd canopy
dotnet restore
dotnet build - to be sure, that it compiles
dotnet pack --version-suffix 999 - to create unique version number

This showed some warnings, but the package has been created:
c:\github\canopy\src\canopy\bin\Debug\canopy.1.0.0-999.nupkg

Then in my project file (MyProject.fsproj) I have added additional local nuget source section (c:\github\canopy\src\canopy\bin\Debug):

<PropertyGroup>
  <RestoreSources>
    $(RestoreSources); 
    C:\github\canopy\src\canopy\bin\Debug; 
    https://api.nuget.org/v3/index.json
  </RestoreSources>
</PropertyGroup>

Then (still in my project):
dotnet add .\MyProject.fsproj package canopy --version 1.0.0-999

After that the package has been added to my project:

...
<ItemGroup>
    <PackageReference Include="Argu" Version="5.1.0" />
    <PackageReference Include="canopy" Version="1.0.0-999" />
  </ItemGroup> 
...

... and there were no warnings:

info : Adding PackageReference for package 'canopy' into project '.\MyProject.fsproj'.
log : Restoring packages for C:\github\MyProject\MyProject.fsproj...
info : CACHE https://api.nuget.org/v3-flatcontainer/fsharp.core/index.json
info : Package 'canopy' is compatible with all the specified frameworks in project '.\MyProject.fsproj'.
info : PackageReference for package 'canopy' version '1.0.0-999' added to file 'C:\github\MyProject\MyProject.fsproj'.

@lefthandedgoat
Copy link
Owner

@zbigniew-gajewski Thanks for the lead. I used paket pack to make these packages and it may have caused a difference. I am on vacation now but when I get home I will see if I can make a new package like you did that does not cause the warning.

Thanks again!

@soerennielsen
Copy link
Contributor

soerennielsen commented Sep 9, 2018

This is actually a real issue.

It may just be a warning but it is killing the build on my TFS build server :-(

Apparently the canopy nuget file is specifying "<group targetFramework="netstandard2.0">" but it seems it should be:
"<group targetFramework=".NETStandard2.0">"

The latter is taken from the Selenium.WebDriver which does not exhibit the issue.

Log file from the build server for Canopy:
Checking compatibility for canopy 2.0.1 with .NETCoreApp,Version=v2.1.
Package canopy 2.0.1 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package canopy 2.0.1 supports: net (.NETFramework,Version=v0.0)

Log file from the build server for Selenium.WebDriver:
Checking compatibility for Selenium.WebDriver 3.14.0 with .NETCoreApp,Version=v2.1.
Package Selenium.WebDriver 3.14.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Selenium.WebDriver 3.14.0 supports:

  • net35 (.NETFramework,Version=v3.5)
  • net40 (.NETFramework,Version=v4.0)
  • net45 (.NETFramework,Version=v4.5)
  • netstandard2.0 (.NETStandard,Version=v2.0)

so obviously some translation between ".NETStandard2.0" to "netstandard2.0" is going on within nuget. It is likely a very simple fix. Pretty please ;-)

.net core 2.0 (and 2.1) would also be nice though not at all a requirement as Selenium doesn't either.

(note that I've build and tested this with .NETCore 2.0, 2.1 and .NET standard 2.0. It is all the same.

@lefthandedgoat
Copy link
Owner

Later today I have some free time and I will try switching to .NETStandard2.0 to see if that fixes it. Thanks!

@lefthandedgoat
Copy link
Owner

I think this will fix it for you. It was an epic journey to figure out the slightest thing to change.

https://www.nuget.org/packages/canopy/2.1.0

This line fixed it: 9135bdd#diff-beb5bdc57f593a54f2fcbbdd7ebc489aR21

Problem was that I was making these changes, building a new package and testing locally. VS was SO NICE TO ME and kept installed old cached versions of a package that did not work. I was only able to see any changes working by updating the package number so there was no caching. Hours.... it took lol.

Hope this fixes TFS for you!

@soerennielsen
Copy link
Contributor

It works!

Sorry that you had to go the long way around it. I too have been burned by nuget packages in the past when I created a few.

it was the ".nuget" cache folder?

I tested:
.NET standard 2.0 👍
.NET standard 2.1 👍 (defaulted fine back)
.NET core 2.1: 👎 (defaulted to .net Framework).

The last one is not critical to me, as I can use .NET standard instead just fine. Just curious that it wouldn't default back to .NET standard.

THANK you.

@soerennielsen
Copy link
Contributor

One final note:

Please be sure to use Nuget >=4.3.0 as that one will know that a .Net Core app can default back to use .Net standard packages.
Had some fun with this as .NET Standard dll's cannot be executed within a docker container (it seems only VS will allow it).

I think that this issue can be closed now :-)

@lefthandedgoat
Copy link
Owner

Use Nuget 4.3.0 client?

@soerennielsen
Copy link
Contributor

Yes, on the build server I had to add a little powershell script to download Nuget 4.3.0 and use that one.

On Desktop it was fine with a later version of VS 2017.

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

5 participants