179

I cloned the ASP.NET Core SignalR Repo locally, and try opening the solution from within the following environment.

IDE

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01055

DOT NET CLI

λ dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
 Version:            1.0.0-preview2-1-003177
 Commit SHA-1 hash:  a2df9c2576

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64

I end up seeing a lot of these kinds of error messages:

..\Repos\SignalR\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj : error : The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format. ..\Repos\SignalR\src\Microsoft.AspNetCore.SignalR\Microsoft.AspNetCore.SignalR.csproj

I want to know how to fix this the correct way.

DavidG
  • 113,891
  • 12
  • 217
  • 223
David Pine
  • 23,787
  • 10
  • 79
  • 107
  • I just assumed that I would be able to, is that an assumption I should not make? I would hope that this is backwards compatible. – David Pine Feb 28 '17 at 12:56
  • 1
    Well I'm getting this error after allowing VS2017 RTM to update the project format :-( – Simon_Weaver May 19 '17 at 09:45
  • i posted a similar error here.. https://stackoverflow.com/questions/58336983/visual-studio-2015-error-the-default-xml-namespace-of-the-project-must-be-the-m , however in my case i am starting with a new proj, not trying to open an existing one. – joedotnot Oct 11 '19 at 08:16

7 Answers7

229

The projects you are trying to open are in the new .NET Core csproj format. This means you need to use Visual Studio 2017 which supports this new format.

For a little bit of history, initially .NET Core used project.json instead of *.csproj. However, after some considerable internal deliberation at Microsoft, they decided to go back to csproj but with a much cleaner and updated format. However, this new format is only supported in VS2017.

If you want to open the projects but don't want to wait until March 7th for the official VS2017 release, you could use Visual Studio Code instead.

David Pine
  • 23,787
  • 10
  • 79
  • 107
DavidG
  • 113,891
  • 12
  • 217
  • 223
  • I'm very familiar with the history, I guess I just assumed that this would work. The error doesn't seem like it's too far gone from the realm of possible. Are you certain that there is no way to get this to work with minimal effort for the time being, without the **Visual Studio 2017 RC** bits? – David Pine Feb 28 '17 at 13:03
  • Not with VS2015, no. That's why I offered VS Code as an alternative. At least you only have a week to wait for VS2017 to be released :) – DavidG Feb 28 '17 at 13:07
  • That's true, thanks! What version of the **DOT NET CLI** do I need if I'm to use **VS Code**? – David Pine Feb 28 '17 at 13:08
  • 2
    @ThePartyTurtle To be fair, that would be asking VS2015 to understand a file format that it's never going to support. – DavidG Jun 06 '17 at 23:24
59

I ran into this issue while opening the Service Fabric GettingStartedApplication in Visual Studio 2015. The original solution was built on .NET Core in VS 2017 and I got the same error when opening in 2015.

Here are the steps I followed to resolve the issue.

  • Right click on (load Failed) project and edit in visual studio.
  • Saw the following line in the Project tag: <Project Sdk="Microsoft.NET.Sdk.Web" >

  • Followed the instruction shown in the error message to add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to this tag

It should now look like:

<Project Sdk="Microsoft.NET.Sdk.Web" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  • Reloading the project gave me the next error (yours may be different based on what is included in your project)

"Update" element <None> is unrecognized

  • Saw that None element had an update attribute as below:

    <None Update="wwwroot\**\*;Views\**\*;Areas\**\Views">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </None>
    
  • Commented that out as below.

    <!--<None Update="wwwroot\**\*;Views\**\*;Areas\**\Views">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </None>-->
    
  • Onto the next error: Version in Package Reference is unrecognized Version in element <PackageReference> is unrecognized

  • Saw that Version is there in csproj xml as below (Additional PackageReference lines removed for brevity)

  • Stripped the Version attribute

    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" />
    
  • I now get the following: VS Auto Upgrade

Bingo! The visual Studio One-way upgrade kicked in! Let VS do the magic!

  • The Project loaded but with reference lib errors. enter image description here

  • Fixed the reference lib errors individually, by removing and replacing in NuGet to get the project working!

Hope this helps another code traveler :-D

DavidG
  • 113,891
  • 12
  • 217
  • 223
Jersey_Guy
  • 867
  • 7
  • 18
  • 3
    @DavidG It's not a waste of time since not all projects have a VS2015 branch. – usr-bin-drinking Feb 14 '19 at 20:51
  • Need to add that you have to click "Show All Files" in the Solution Explorer toolbar in order to see the folders of the project, again. They will appear "dotted out" and you'll need to right-click and select each one and select "Include in Project" to re-institute them in. – vapcguy Jan 27 '20 at 21:21
  • These were exactly the issues that I faced ..step by step followed them..Thanks!! – Samra Jul 22 '20 at 02:43
15

@DavidG's answer is correct, but I would like to add that if you're building from the command line, the equivalent solution is to make sure that you're using the appropriate version of msbuild (in this particular case, it needs to be version 15).

Run msbuild -version to see which version you're using or where msbuild to check which location the environment takes the executable from and update (or point to the right location of) the tools if necessary.

Download the latest MSBuild tool from here.

Jess
  • 23,901
  • 21
  • 124
  • 145
Nikita R.
  • 7,245
  • 3
  • 51
  • 62
6

If getting this error trying to build .Net Core 2.0 app on VSTS then ensure your build definition is using the Hosted VS2017 Agent queue.

Scotty.NET
  • 12,533
  • 4
  • 42
  • 51
  • I had a similar problem with a VS Azure Functions project that targeted .net framework but still generated the csproj file in a core format. This fix worked for me. – ElliotSchmelliot Jun 19 '18 at 23:54
5

I was getting the same messages while I was running just msbuild from powershell.

dotnet msbuild "./project.csproj" worked for me.

Alex Narbut
  • 126
  • 1
  • 3
  • 1
    This is basically the same answer as [this one](https://stackoverflow.com/a/44166281/1663001). You need to be using the latest version of msbuild. – DavidG Jan 26 '19 at 14:01
0

if the project is not a big ,

1- change the name of folder project

2- make a new project with the same project (before renaming)

3- add existing files from the old project to the new project (totally same , same folders , same names , ...)

4- open the the new project file (as xml ) and the old project

5- copy the new project file (xml content ) and paste it in the old project file

6- delete the old project

7- rename the old folder project to old name

0

I had the same problem and solved it by using dotnet instead of msbuild.

Thoker
  • 90
  • 1
  • 10