Javascriptservices: MSBUILD : error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

Created on 7 Dec 2016  路  31Comments  路  Source: aspnet/JavaScriptServices

I'm getting this error:

Build FAILED.
       "c:\Users\ranbu\Documents\dev\creators3d-dot-net-core\project.json" (Build target) (1) ->
         MSBUILD : error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. [c:\Users\ranbu\Documents\dev\creators3d-dot-net-core\project.json]
    0 Warning(s)
    1 Error(s)

I think it's not working since I've installed Visual Studio 2017 RC but I'm still using VS Code.

(I haven't migrated my project to Visual Studio 2017)

Most helpful comment

If you've installed VS2017RC, then your machine now has .NET Core Tools Preview 3 on it. That's not compatible with project.json-based projects such as yours.

There's an easy solution though :) Just add a file called global.json at the root of your project containing this:

{
  "sdk": { "version": "1.0.0-preview2-1-003177" }
}

Now the build system will know to build it using the Preview 2 tools.

All 31 comments

If you've installed VS2017RC, then your machine now has .NET Core Tools Preview 3 on it. That's not compatible with project.json-based projects such as yours.

There's an easy solution though :) Just add a file called global.json at the root of your project containing this:

{
  "sdk": { "version": "1.0.0-preview2-1-003177" }
}

Now the build system will know to build it using the Preview 2 tools.

I already have a global.json file and he looks like this:

{
  "sdk": { "version": "1.0.0-preview2-003121" }
}

I've tried to change it to what you've suggested but I'm still getting the same error.

Do you have that version of .NET Core tools (preview2) installed on your machine as well? @ranbuch

C:\Users\ranbu>dotnet --info
.NET Command Line Tools (1.0.0-preview3-004056)

Product Information:
 Version:            1.0.0-preview3-004056
 Commit SHA-1 hash:  ccc4968bc3

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

How can I know if I have preview2 as well? I probably use to have . . .

Downloaded preview2 from here: https://www.microsoft.com/net/core#windowsvs2015

and installed it but dotnet --info still returns preview3 version.

Can you try installing the "Current" SDK ? https://www.microsoft.com/net/download/core#/current

That's what I've installed again, The link that you shared here is preview2.

@SteveSandersonMS can you please re-open this issue?

@ranbuch It doesn't seem like an issue in any JavaScriptServices code, so it's not like we can change anything in this repo to fix it. It only appears that you don't have the correct SDK installed. Please check c:\Program Files\dotnet\sdk and verify you have installed the 1.1 SDK whose version matches your global.json file.

If you are able to repro the issue in a way that points to it being specific to JavaScriptServices, please do let us know. For example, if you can take your failing project, strip out the JavaScriptServices code, and it starts working (without changing global.json or which SDKs are installed), that would imply there's an issue in this repo.

Understood, Thank you @SteveSandersonMS

@ranbuch

dotnet --info still returns preview3 version

Try running that from the folder that contains global.json. In the absence of a global.json, I believe the CLI always resolves to the subfolder of %PROGRAMFILES%dotnet\sdk that represents the greatest semver version.

hi, the solution for me was uninstall preview3 from the programs list

Thank you @miyelo

@miyelo thanks - also solved the problem for me

thanks @miyelo

@ranbuch I had Visual Studio 2017 installed on my mac. I removed it from applications directory. But I am still confused what version of dotnet to install that would support project.json & that docs.microsoft.com are following

Hi @AbhimanyuAryan ,
As already written above, go to c:\Program Files\dotnet\sdk and check what's the exact preview2 version you have installed on your machine (Ignore the preview3 version).
Then match it on your global.json file.

What's in the local I should check in case of OSX?

I believe the new version does not support the global.json so it is being ignored if you have installed preview3.

Edit: Looks like this is not true. I should have verified before posting.

@thesmallbang I have 1.0.0-rc4-004771

Restore using command prompt, it works for me.

Added the global.json file and it worked for me.

I had if not excatly the same problem, but similar. To get a more specific error, I built the solution using msbuild from command line:

msbuild Data.sln /t:Build /p:RunOctoPack=true

Instead of just:
error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

I got (something like this):
The solution file contain a reference to a project with Guid xxxxxx, but no such project was found.

Found the solution here:
https://therightjoin.wordpress.com/2014/07/04/msb4025-the-project-file-could-not-be-loaded-data-at-the-root-level-is-invalid-error-when-building-ssdt-project-in-teamcity/

@summoncse Thank you, it works for me!

I know this is closed but just a point as I came across with my repo. In my case I am building my website from a subdirectory of the repo. The global.json must exist in the root of the repo, not the site to be built.

Hey
@ranbuch had you fixed this issue?

For me the issue has been resolved.
I still have to refresh the page after every code change or I'm getting:

Error in :0:0 caused by: The selector "app" did not match any elements

Is there some way to better adjust the project after migration?

it works just run "dotnet restore" under package manager console. 馃憤

Thanks @joepadz

It fixed my issue

run "dotnet restore" under package manager console.

Deleting the .targets, .cache, .props, . q.targets files inside obj folder and run dotnet restore works for me.
I am using VS Code btw

I solve the same problem in my project by

Tools -> NuGet Package Manager -> Package Manager Console
Select required project from 'Default Project' list
Run the command "dotnet restore" on Package Manager Console
Rebuild the your project again this will solve your problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sampath-Lokuge picture Sampath-Lokuge  路  4Comments

natemcmaster picture natemcmaster  路  4Comments

dougabugg picture dougabugg  路  3Comments

justinyoo picture justinyoo  路  3Comments

uNkNowN92-git picture uNkNowN92-git  路  3Comments