Skip to content

Cannot transitively reference a csproj+project.json #1112

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

Closed
gulbanana opened this issue Apr 11, 2017 · 8 comments
Closed

Cannot transitively reference a csproj+project.json #1112

gulbanana opened this issue Apr 11, 2017 · 8 comments

Comments

@gulbanana
Copy link

Steps to reproduce

  1. Clone https://github.com/gulbanana/repro-transitive-projectjson
  2. dotnet build
  3. error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

The bug also occurs when building in Visual Studio.

@gulbanana
Copy link
Author

I've verified that the problem also happens when building with full-framework commandline MSBuild (version 15.1.1012.6693)

@livarcocc
Copy link
Contributor

@AndyGerlicher @rainersigwald can you guys help take a look?

@gulbanana please note that this will not work through dotnet build, as the CLI does not support old style csproj files.

@rainersigwald
Copy link
Member

I don't see this with msbuild /t:restore && msbuild in that repo. Can you share a diagnostic log? What file is allegedly invalid, and what are its contents?

@gulbanana
Copy link
Author

Oh wow, i had unpushed commits in my local copy of the repo.. sorry, it should reproduce now!

Here's the output of msbuld /t:restore && msbuild /v:diag: https://gist.github.com/gulbanana/40d54c41f83a73bfc7aa6ad8c68ffef5

The content of the project.json file which is claimed to be invalid:

{
  "runtimes": {
    "win": {}
  },

  "frameworks": {
    "net461": {}
  },

  "dependencies": {
    "Newtonsoft.Json": "9.0.1"
  }
}

My guess is that the MSB4025 error indicates it's trying to load the project.json as an msbuild project file, which of course won't work.

@rainersigwald
Copy link
Member

rainersigwald commented Apr 18, 2017

With that I'm now able to reproduce this, thanks.

You're right--the SDK includes transitive project references as ProjectReferences, which are then built with the <MSBuild> task, which then errors because in this case, the reference is a path to the project.json file, rather than the %(ResolvedPath), which is the path to the .csproj. See 11821-11833 in your log.

It looks like this was done intentionally in #478, but I don't know the full implications. @emgarten, is this a problem in the SDK layer, or is NuGet reporting bad information here?

@emgarten
Copy link
Member

This looks like the same issue as #922

The error there is:

3>E:\dotnetsdkerror\ClassLibrary1\project.json(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.
3>Done building project "project.json" -- FAILED.

The workaround for this is to reference the project directly instead of getting it as a transitive project reference.

@gulbanana
Copy link
Author

That workaround works (around) for me.

@livarcocc
Copy link
Contributor

Let's track it though #922.

mmitche pushed a commit to mmitche/sdk that referenced this issue Jun 5, 2020
…118.10 (dotnet#1112)

- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19568.10
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