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

dotnet build fails when referencing a project converted to PackageReference #6294

Closed
gulbanana opened this Issue Apr 11, 2017 · 10 comments

Comments

Projects
None yet
5 participants
@gulbanana
Copy link

gulbanana commented Apr 11, 2017

This problem prevents us from performing continuous integration or scripted builds.

Steps to reproduce

  1. Clone https://github.com/gulbanana/repro-packagereference-transitive
  2. cd SdkProject
  3. dotnet restore
  4. Build in Visual Studio
  5. dotnet build

Expected behavior

Both the VS and commandline builds should succeed.

Actual behavior

Commandline build fails with this error:
FPClass.cs(5,16): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?) [C:\code\repro-packagereference-transitive\FrameworkProject\FrameworkProject.csproj]
It appears that the PackageReference isn't being resolved properly when built this way.

Visual Studio uses full-framework msbuild, so I also tried just running msbuild, which failed with a different error:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\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 pr oject.json and then re-run NuGet restore. [C:\code\repro-packagereference-transitive\FrameworkProject\FrameworkProject.csproj]
Seems misleading, since I don't have a project.json file.

dotnet --info

.NET Command Line Tools (1.0.2)

Product Information:
Version: 1.0.2
Commit SHA-1 hash: 54743c8

Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.2

@gulbanana

This comment has been minimized.

Copy link
Author

gulbanana commented Apr 11, 2017

Note: if I replace the PackageReference with a project.json, dotnet build still fails, but full-framework msbuild succeeds. The msbuild -version is Microsoft (R) Build Engine version 15.1.1012.6693

@emgarten

This comment has been minimized.

Copy link
Collaborator

emgarten commented Apr 11, 2017

Add a <RuntimeIdentifier>win</RuntimeIdentifier> to your project to match what project.json required. I thought this was already fixed in the latest Visual Studio 15.1, but if not just provide the RIDs in the project.

For legacy csproj projects using PackageReference the errors still refer to project.json, however the same thing applies for the csproj file. Updating this is tracked here: NuGet/Home#4778

@emgarten

This comment has been minimized.

Copy link
Collaborator

emgarten commented Apr 11, 2017

Also for non-NETCore SDK projects you will need to use full-framework msbuild.

@livarcocc

This comment has been minimized.

Copy link
Member

livarcocc commented Apr 11, 2017

Correct, CLI does not support old style csproj.

@livarcocc livarcocc closed this Apr 12, 2017

@gulbanana

This comment has been minimized.

Copy link
Author

gulbanana commented Apr 12, 2017

I see. dotnet/sdk#1112 covers the rid-needed issue, then. The problem with this is that nuget.exe doesn't support new style csproj - so neither dotnet pack nor nuget pack are usable. How are we to pack new style projects with references to old style projects?

@livarcocc

This comment has been minimized.

Copy link
Member

livarcocc commented Apr 12, 2017

@emgarten about nuget.exe not supporting new style csprojs.

@emgarten

This comment has been minimized.

Copy link
Collaborator

emgarten commented Apr 12, 2017

@rohit21agrawal for pack

@StingyJack

This comment has been minimized.

Copy link

StingyJack commented Apr 19, 2017

If this is still happening to you...

  1. close the solution
  2. delete the .suo and DotSettings.user (if you have that one) files for the solution
  3. delete the .csproj.user file for the project with the error

... and then reopen VS.

@gulbanana

This comment has been minimized.

Copy link
Author

gulbanana commented Apr 19, 2017

@StingyJack, none of that will help as the problem is a design issue rather than a transient bug.

I'll go figure out what repository is appropriate to open an issue about how to pack this combination of projects and we can leave this one closed.

@rohit21agrawal

This comment has been minimized.

Copy link
Collaborator

rohit21agrawal commented Apr 19, 2017

@gulbanana build related issues can either be filed at github.com/dotnet/sdk or github.com/dotnet/cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.