Azure deployment: error MSB4041: The default XML n

2020-05-02 13:22发布

问题:

I'm continuously deploying my Azure Web App as usual (using Visual Studio Community 2019) but now I'm getting the following error.

(Also, I've already seen this question: The default XML namespace of the project must be the MSBuild XML namespace, but I'm only getting this error in the logs in the Deployment Centre of my Azure Web App, and that question relates to Visual Studio 2017.)

"WebApp" is the name of the solution:

D:\home\site\repository\packages\EntityFramework.6.3.0\build\EntityFramework.props(1,1): error MSB4041: 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 <Project> element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format. [D:\home\site\repository\WebApp.WebUI\WebApp.WebUI.csproj] Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\WebApp.WebUI\WebApp.WebUI.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="D:\local\Temp\8d75ccda63e5816";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="D:\home\site\repository\.\\" An error has occurred during web site deployment. \r\nD:\Program Files (x86)\SiteExtensions\Kudu\84.10924.4104\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

Here's the start of my WebApp.WebUI.csproj file:

<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="..\packages\EntityFramework.6.3.0\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.3.0\build\EntityFramework.props')" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

UPDATE: I've downgraded to Entity Framework 6.2.0. It's now working, but this isn't a good solution. The problem is with the Entity Framework 6.3.0 package and/or how it interacts with my current configuration.

回答1:

Could you please try modifying your project node like below, it worked for me:

<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Additional reference:

http://blog.codenova.pl/post/new-azure-functions-sdk-and-vsts-how-to-build-your-functions

Let me know if still doesn't work for you.



回答2:

I think this issue has something to do with the msbuild version. I googled some similar issues and found that the EF6.3 requires at least VS2017 and higher. And if we use msbuild 14.0(VS2015) to build a web-project consuming EF6.3, we'll get same error like this:

Cause of your issue:

And according to your log(line7):Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" ,during that process, it's using msbuild 14.0(msbuild of VS2015). I think that's why you have that strange error.

1.To resolve that issue, in local machine, we need to use VS2017(msbuild15.0) or VS2019(msbuild16.0) to build that project.

The path of msbuild 15.0: C:\Program Files (x86)\Microsoft Visual Studio\2017\xxx\MSBuild\15.0\Bin

The path of msbuild 16.0: C:\Program Files (x86)\Microsoft Visual Studio\2019\xxx\MSBuild\Current\Bin

2.As for msbuild support for Azure: please check this issue. Now Azure has support for VS2017 build tools(msbuild 15.0), please try the useful info there to configure your deployment to use msbuild 15.0.

Hope it makes some help :)



回答3:

Entity Framework 6.4.0 works. (6.3.0 will not.)



回答4:

If there is any way to find out your Visual Studio version for Azure deployment. Not the local VS version but the server one, which is being used to build your project while deploying on Azure. I feel that's lower than 2017.

Update: Since the VS version is 2015, you would not be able to upgrade until you upgrade the VS version as well.

EF 6.3 uses the new csproj format and requires VS 2017 and above. If you degraded to EF 6.2 and it built fine. So for your case, please try with VS2017 or above to build the project for Azure deployment.