I have build this project as .Net standard project and i am facing this error issue in jenkins when I build this project:
C:\Users\tahab.jenkins\workspace\Mondaytest\Calculator\Calculator.csproj(1,1):
error MSB4041: The default XML namespace of the pr.oject 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
Make sure you use recent versions of the MSBuild task you use to build your project.
You need too use the Visual Studio 2017 (Build Tools, Full, ..) version of MSBuild - which is local to the Visual Studio installation - to build your project.
You may need to confiure the path to MSBuild, which would be - depending on the version installed on the build gent - similar to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
This error happens if you try to build new projects with older versions of Visual Studio / MSBuild or even with the old version of MSBuild that is part of .NET Framework.
Related
What is current Toolversion for MS Build ToolVerions for VS2022 and what would be Framework version for .NetFramework. what is the version i can see in CsProj in project
Visual Studio 2022 ToolVersion in Csproj for .NetFrameWork
Here is the Description of ToolsVersion:
The version of the Toolset MSBuild uses to determine the values for $(MSBuildBinPath) and $(MSBuildToolsPath).
MSBuild is installed in the \Current folder under each version of Visual Studio. You just need to change ToolsVersion="15.0" to ToolsVersion="Current" if you want to use MSBuild 17.0 in your project in Visual Studio 2022.
You can find the current folder from here C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current
We can also see this from the detailed build output window:
Project file contains ToolsVersion="15.0". This toolset may be unknown
or missing, in which case you may be able to resolve this by
installing the appropriate version of MSBuild, or the build may have
been forced to a particular ToolsVersion for policy reasons. Treating
the project as if it had ToolsVersion="Current". For more information,
please see http://go.microsoft.com/fwlink/?LinkId=293424.
The build may have been forced to ToolsVersion="Current" because the toolset for 15.0 could not be found. So it is not necessary to modify ToolsVersion.
For Visual Studio 2022 and .Net Framework projects use ToolsVersion="Current" or ToolsVersion="17.0". (The version of MSBuild that comes with VS2022 is 17.0.)
See more detail at MSBuild Toolset (ToolsVersion).
When a new project is created Visual Studio uses a template. From the comments it appears that the template has not been updated since VS2017 and has ToolsVersion="15.0". MSBuild 15 was provided with VS2017. You can simply edit the project file and update the ToolsVersion. If you only have VS2022 or MSBuild v17 installed, that version of MSBuild will be used even when the ToolsVersion is set to 15.
I have a solution, mostly made up of .NET Framework 4.5 projects.
Recently, we added a project (library) that targets both netstandard2.0 and net45.
This was achieved by making the following amendments to the .proj file of the new library.
This builds fine in VS2019, but when pushed to Azure DevOps (building using the VS2019 agent) it fails with the following error.
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 element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.
Can anyone please advise?
Edit 1:
Here is my YAML...
PublishProfile: 'VSORelease'
steps:
- task: VSBuild#1
displayName: 'Build solution Retailer/Retailer.sln'
inputs:
solution: Retailer/Retailer.sln
vsVersion: 16.0
msbuildArgs: '/p:DeployOnBuild=true /p:PublishProfile="$(PublishProfile)"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
It appears that (even though I am able to choose VS2019 as an option in my build pipeline)... Visual Studio 2019 isn't available on Azure DevOps?
[warning] Visual Studio version '16.0' not found. Falling back to version '14.0'.
Any idea how I can get this to work?
Build Error on Azure DevOps - Solution made up of multiple target frameworks
Since you are using Visual Studio 2019 on your local, so you should build the solution on the Azure Devops with agent Hosted Windows 2019 with VS2019, which with Visual Studio installed by default.
Hope this helps.
Project Setup : Mixed framework solution
.Net Framework 4.6.2 projects in solution : 15
.Net Standard 2.0 projects in solution - 1
Development Machine
Visual Studio 2017(15.7.4) : Builds without any errors
Build Server
TeamCity Version 2017.1.3
Build Steps
Nuget Restore(3.4.4)
dotnet Restore
MSBuild( Build Tools 2017), Tools Version 15.0
Build fails with following error in the .net standard 2.0 project : [ResolvePackageAssets] C:\Program Files\dotnet\sdk\2.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198, 5): Package System.Security.Cryptography.ProtectedData, version 4.4.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
What's interesting is I can't find reference or use of System.Security.Cryptography.ProtectedData anywhere in the project. Any help is greatly appreciated.
P.S - Can't use dotnet build, as the solution needs building of licenses.licx files, and the component which builds it (Microsoft.Build.Tasks.LC) is not ported to .Net Core. The suggestion from various posts was to use MsBuild.exe
I have an ASP.NET Core 1.1.2 project targeting .NET Framework 4.6.2. I recently installed the latest version of Visual Studio (15.2 26430.16), and now I can't build the project using MSBuild version 15.1.1012.6693. The error occurs when using a PublishProfile.
The MSBuild command is:
msbuild D:\project\project.csproj /p:DeployOnBuild=true /p:PublishProfile=dist
And the error is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(54,5):
error MSB4062: The "TransformWebConfig" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Publish.Tasks.dll.
Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
[D:\project\project.csproj]
It works when not specifying a publish profile. However when publishing the project from Visual Studio, everything works as expected.
This is known bug of the tooling when building using the 64 bit MSBuild version (build server, command line). See this GitHub issue for details.
Since this issue has been fixed, you need to upgrade to the recently released 15.3.* versions of Visual Studio / MSBuild and probably also 2.0.0 version of the .NET Core SDK.
On a Windows Server 2003 R2 with .NET 4 SDK but without Visual Studio 2010, I have tried building a Visual Studio 2010 solution with
msbuild MySolution.sln /p:RunCodeAnalysis=true
but that fails.
What is required to run code analysis on such an environment?
I get this error message:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(129,9): error MSB6003:
The specified task executable "FxCopCmd.exe" could not be run.
Could not load file or assembly
'Microsoft.VisualStudio.CodeAnalysis.Sdk, Version=10.0.0.0, Culture=neutral, PublicKeyToken= b03f5f7f11d50a3a'
or one of its dependencies.
The system cannot find the file specified.
I have installed FxCop from the SDK and without luck pointed the variable FxCopDir to the installed location of FxCopCmd.exe, and also setting this registry entry to that location:
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev#FxCopDir
I had the same problem on my MSBuild server and fixed it by:
Installing Windows SDK 7.1
Setting up the registry keys FxCopDir and StanDir in HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev (in Win32).
I then copied over from the dev PC, to the FxCop folder on the build server, the following:
The folder Rule Sets (default installation target is here: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop)
Microsoft.VisualStudio.CodeAnalysis.Sdk.dll
Microsoft.VisualStudio.CodeAnalysis.Phoenix.dll
phx.dll
Do a search for them on your dev PC with Visual Studio installed to locate them.
Then use the .NET 4.0 version of gacutil.exe to install Microsoft.VisualStudio.CodeAnalysis.Sdk.dll to the GAC.
You should then be able to run code analysis as part of an MSBuild build and have it work properly.
An alternative to FxCop would be to use the tool NDepend that lets write Code Rules over C# LINQ Queries (namely CQLinq). Disclaimer: I am one of the developers of the tool
More than 200 code rules are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the well-known C# LINQ syntax.
Rules can be verified live in Visual Studio and at Build Process time, in a generated HTML+javascript report.
Another option might be calling FxCop executable as a build task (from msbuildtasks), saving the result as an XML file that can be parsed within most of the CI tools (like Hudson and CC.NET)