Itiviti / gradle-msbuild-plugin

Gradle plugin for msbuild execution, supports C# project files for now
Apache License 2.0
102 stars 57 forks source link

Support MSBuild 15 #80

Closed Konstantin-Posudevskiy closed 6 years ago

Konstantin-Posudevskiy commented 6 years ago

Problem

Currently, there is no possibility to build projects, with new format of 'csproj' file, shipped from .NET Core. Build support of new project format came with MSBuild 15.

See project example:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net45</TargetFramework>

    <RootNamespace>Example</RootNamespace>
    <AssemblyName>Example</AssemblyName>

    <PackageId>Example</PackageId>    
    <Authors>Konstantin Posudevskiy</Authors>
    <IncludeSymbols>true</IncludeSymbols>
    <IncludeSource>true</IncludeSource>    
    <NoPackageAnalysis>true</NoPackageAnalysis>
    <PackageTags>.NET</PackageTags>
  </PropertyGroup> 

  <ItemGroup>
    <PackageReference Include="Antlr4" Version="4.3.0" />
  </ItemGroup>
</Project>

Now I receive next exception message:

Error during project file parsing: Microsoft.Build.Exceptions.InvalidProjectFileException: 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.

That is exception stack:

   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Construction.ProjectParser.Parse()
   at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext)
   at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ILoggingService loggingService, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext)
   at Microsoft.Build.Construction.ProjectRootElement.<OpenProjectOrSolution>c__AnonStorey0.<>m__0(String path, ProjectRootElementCache cache)
   at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded)
   at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ILoggingService loggingService, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, Boolean isExplicitlyLoaded)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName)
   at ProjectFileParser.ProjectHelpers.LoadProject(String fullPath, IDictionary`2 args)
   at ProjectFileParser.Program.ParseProject(String file, JObject args)
   at ProjectFileParser.Program.Parse(String file, JObject args)
   at ProjectFileParser.Program.Main(String[] args)
gluck commented 6 years ago

Yes, we probably need to upgrade the parser to some newer MSBuild tooling. The nuget pkg we were using ( https://www.nuget.org/packages/MSBuild/ ) is now unlisted, no idea what it has been replaced by (if anything), if you (or anyone) have any clue.

Thx

ngyukman commented 6 years ago

potentially #77 should help to migrate, but it was failing on linux due to the .Net Framework version

saltatory commented 6 years ago

I would love to have this as well.

ngyukman commented 6 years ago

gradle-msbuild-plugin 2.19 is released