fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
2.02k stars 520 forks source link

Add ResolveNuGetPackages=false property to .fsproj #2354

Open alfonsogarciacaro opened 7 years ago

alfonsogarciacaro commented 7 years ago

Disclaimer: this is a workaround that I've been suggested (and works) for a specific problem I had (described below). I don't know about the generics and whether this is the appropriate solution for all cases. I'm reporting this issue on request ;)

I had an .fsproj file (old format) for an F# Windows/Mono .NET Framework 4.6.1 project with dependencies managed my Paket. After updating Visual Studio to 15.2 I couldn't build the project anymore because of the following error:

error : Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win": { } }' to your project.json and then re-run NuGet restore.

Note I didn't have any project.json as this was not a netcore project. This also happened to FAKE builds as FAKE was calling C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe after VS update.

Thanks to @enricosada help, I could fix the issue by adding the following line to the project properties.

<ResolveNuGetPackages>false</ResolveNuGetPackages>

Maybe it makes sense that Paket adds this line automatically to old .fsproj files?

enricosada commented 7 years ago

It doesnt make a lot of sense. That's an error who happen only on old fsproj if a project.json exists.

@alfonsogarciacaro can you try

and save the output? i should contains some clue.

Adding that by default (for old fsproj) mean will ignore the project.json (used like for uwp, or anyway for package refs). dunno if has others meaning the property

alfonsogarciacaro commented 7 years ago

Here are the outputs, @enricosada, I hope they're helpful :)

prop_false.txt prop_true.txt

enricosada commented 7 years ago

@alfonsogarciacaro so, maybe is the obj\project.assets.json the issue?

Using "ResolveNuGetPackageAssets" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.Build.Tasks.dll".
Task "ResolveNuGetPackageAssets" (TaskId:8)
  Task Parameter:IncludeFrameworkReferences=True (TaskId:8)
  Task Parameter:RuntimeIdentifier=win (TaskId:8)
  Task Parameter:ProjectLanguage=F# (TaskId:8)
  Task Parameter:ProjectLockFile=C:\Users\Alfonso\Documents\GitHub\iris\dotnet\src\Iris\Projects\Core\obj\project.assets.json (TaskId:8)
  Task Parameter:
      ContentPreprocessorValues=
          rootnamespace
                  Value=Iris
          assemblyname
                  Value=Iris.Core
          fullpath
                  Value=C:\Users\Alfonso\Documents\GitHub\iris\dotnet\src\Iris\Projects\Core
          outputfilename
                  Value=Iris.Core.dll
          filename
                  Value=Core.fsproj (TaskId:8)
  Task Parameter:ContentPreprocessorOutputDirectory=obj\x64\Debug\\NuGet (TaskId:8)
  Task Parameter:TargetMonikers=.NETFramework,Version=v4.6.1 (TaskId:8)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(178,5): error : Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win": { } }' to your project.json and then re-run NuGet restore. [C:\Users\Alfonso\Documents\GitHub\iris\dotnet\src\Iris\Projects\Core\Core.fsproj]
  Output Item(s): 
      _ReferencesFromNuGetPackages=
alfonsogarciacaro commented 7 years ago

it's OSS so i can see it?

No, sorry :/

in the same dir you use the new fsproj? that may create the project.assets.json

Not in the same dir, but I do use the new fsproj in the same repo for Fable. Maybe that confuses Paket?

run with previous msbuild works?

Yes, it worked.

there is a way to have a repro of this? just fsproj/deps without source files is enough probably, these doesnt matter

I can try to clean our repo and have something to reproduce the situation but I'm a bit short on time recently. Personally, I'm already happy because the problem is solved (thanks to your help!), I just wrote the issue because @forki asked for it ;)

enricosada commented 7 years ago

Yes, this issue helps anyway, is good anyway to have a workaround here just googling.

Let's wait for another repro, maybe is just a transitory interaction, cannot thing about anything atm.

To directly add ResolveNuGetPackages in paket maybe is an idea, but need to check what exacly enable/disable in all sdk (old and new). maybe can be added only for old sdk (old fsproj/csproj)? there is harmless afaik. Can be a solution @forki ?