aspnet / Templates

This repo is OBSOLETE - please see the README file for information

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

brentarias opened this issue · comments

This issue is similar(?) to another issue by the same name posted to aspnet/javascript services. The solutions posted there are not applicable for my scenario.

I have Visual Studio 2015 Update 3 installed. I do not have Visual Studio 2017 installed. The ASP.NET Core Web Application (.Net Framework) is creating new projects that are DOA. The IDE says "package restore failed" and the output window shows the error:

\documents\visual studio 2015\Projects\FullWebCore2.vs\restore.dg(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

The details...
I was surprised to see that the template created for me a solution with a global.json which contained the following:

"sdk": {
  "version": "1.0.0-preview1-002702"
}

I expected the template to give me a much later version (at least preview 2 or preview 3). The easiest (?) explanation for this is when I run dotnet --info which gives me:

Version: 1.0.0-preview1-002702

I am not interested in the very latest dotnet core, but I at least want version 1.0.0-preview2-003121 if not 1.0.1. So...

I then check to see what versions of dotnet core I currently have installed and in the \program files\dotnet\sdk folder I see these folders:

  • 1.0.0-preview1-002702
  • 1.0.0-preview2-003121
  • 1.0.1

From this I concluded that I will uninstall and re-install .NET Core SDK 1.0.1 (x64). I check dotnet --info again and now I see:

Version: 1.0.1

Good. Again, version 1.0.1 is "late" enough for me. I go back and re-create an ASP.NET Core Web application from Visual Studio but unfortunately it still creates the old format with the 1.0.0-preview1-002702 version. Likewise, the original "package restore error" persists.

Is this behavior expected?

I found the solution. My Visual Studio had "Microsoft ASP.NET and Web Tools" extension version 14.1.20512.0 installed. I upgraded to 14.1.2111.0 and I was then able to create an ASP.NET project from a template, and watch it successfully restore and build.

In case it helps someone, the VS extension upgrade exe has two other names:

  • VS2015Tools.Preview2.0.3.exe
  • DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe

Again, evidently the two above names are synonymous.

The solution here is correct, please always use the latest version of the tools to ensure the best experience