microsoft / MSBuildLocator

An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.
Other
220 stars 83 forks source link

Packaged .props and .targets files are invalid in MSBuild 14 and lower #52

Closed TomKuhn closed 5 years ago

TomKuhn commented 5 years ago

Both files should start with

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

and not just

<Project>

If you use Microsoft.Build.dll from visual studio 2015, and try to load a csproj that has had Microsoft.Build.Locator nugetted into it, then LoadProject API will fail, complaining about a missing schema

TomKuhn commented 5 years ago

Here's a repro using msbuild.exe

"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
msbuild some_project_referencing_microsoft_build_locator.csproj

Output:

packages\Microsoft.Build.Locator.1.0.31\build\Microsoft.Build.Locator.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:\zzz\dev\tools\xxxxx.csproj]
rainersigwald commented 5 years ago

I'm not opposed to this but it doesn't seem like a high priority to support building projects that use Locator with VS prior to 2017, since the resulting output would only work with 2017/MSBuild 15+.

dfev77 commented 5 years ago

Come on guys is not right! This should be backward compatible. There are a number of integration systems out there that do not have latest VS/msbuild

In my case I try to build a tool that will later be used to compile applications (because VS does no longer register MSBuild in GAC) and I cannot build the tool because the props file is not usable before msbuild 15. So we are back to egg and chicken.

https://ci.appveyor.com/project/gluck/gradle-msbuild-plugin/builds/21466162

dfev77 commented 5 years ago

See #57 for a proposed fix