Itiviti / gradle-dotnet-plugin

Gradle plugin for interacting with dotnet cli
Apache License 2.0
19 stars 8 forks source link

.NET 5.0 - project parsing failed #5

Closed red55 closed 3 years ago

red55 commented 3 years ago

Hi, First of all thanks a lot for you outstanding work.

Using gradle-dotnet-plugin 1.3.7. Got following error, after installing .NET 5.0 SDK to build net5.0 projects.

bash-4.2$ dotnet run -- /var/lib/jenkins/workspace/FTS/CSI.TAO.Reporter/CSI.TAO.Reporter.sln "{'configuration':'Release','maxCpuCount':'4','PublishProfile':'FolderProfile','Configuration':'Release','Version':'1.0.0.1','PackageVersion':'1.0.0.1'}"
Registered latest VS Instance: .NET Core SDK - 5.0.100 - /usr/share/dotnet/sdk/5.0.100/ - DotNetSdk - /usr/share/dotnet/sdk/5.0.100/
Error during project file parsing: Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK resolver type "WorkloadSdkResolver" failed to load. Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
  /var/lib/jenkins/workspace/FTS/CSI.TAO.Reporter/CSI.TAO.Reporter/CSI.TAO.Reporter.csproj
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

File name: 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

   --- End of inner exception stack trace ---
   at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
   at Microsoft.Build.Shared.ProjectFileErrorUtilities.ThrowInvalidProjectFile(BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolvers(String resolverPath, LoggingContext loggingContext, ElementLocation location, List`1 resolvers)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolvers(LoggingContext loggingContext, ElementLocation location)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.Initialize(LoggingContext loggingContext, ElementLocation location)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio)
   at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.<>n__0(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio)
   at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.<>c__DisplayClass3_0.<ResolveSdk>b__1()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, String toolsVersion)
   at ProjectFileParser.ProjectHelpers.LoadProject(String fullPath, IDictionary`2 args) in /var/lib/jenkins/workspace/FTS/CSI.TAO.Reporter/build/tmp/dotnet/ProjectHelpers.cs:line 37
   at ProjectFileParser.ProjectHelpers.<>c__DisplayClass0_0.<GetProjects>b__1(ProjectInSolution p) in /var/lib/jenkins/workspace/FTS/CSI.TAO.Reporter/build/tmp/dotnet/ProjectHelpers.cs:line 17
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at ProjectFileParser.ProjectHelpers.GetProjects(SolutionFile solution, IDictionary`2 args) in /var/lib/jenkins/workspace/FTS/CSI.TAO.Reporter/build/tmp/dotnet/ProjectHelpers.cs:line 15
   at ProjectFileParser.Program.ParseSolution(String file, JObject args) in /var/lib/jenkins/workspace/FTS/CSI.TAO.Reporter/build/tmp/dotnet/Program.cs:line 36
   at ProjectFileParser.Program.Parse(String file, JObject args) in /var/lib/jenkins/workspace/FTS/CSI.TAO.Reporter/build/tmp/dotnet/Program.cs:line 31
   at ProjectFileParser.Program.Main(String[] args) in /var/lib/jenkins/workspace/FTS/CSI.TAO.Reporter/build/tmp/dotnet/Program.cs:line 17

System info:

bash-4.2$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
bash-4.2$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     centos
 OS Version:  7
 OS Platform: Linux
 RID:         centos.7-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.100/

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  3.0.103 [/usr/share/dotnet/sdk]
  3.1.404 [/usr/share/dotnet/sdk]
  5.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download 

ProjectFileParser.csproj contains Target framework refence netcoreapp3.0 - reached EoS on March 2020. I tried to set netcoreapp3.1 the error is the same. If I specify net.50 - everything is OK.

Looks like MS broke tooling with NET 5.0 release. Maybe some quick fix could be applied to ProjectFileParser.csproj like this:

<TargetFramework Condition="$(msbuildversion.StartsWith('16.8')">net5.0</TargetFramework>
<TargetFramework Condition="$(msbuildversion.StartsWith('16.7')">netcoreapp3.1</TargetFramework>
ngyukman commented 3 years ago

hi, thanks for your report Indeed we need to use net5.0 and update the dependencies to better support net5.0 csproj

let's release a new version that expect minimum requirement for net5.0 as msbuild 16.8 can target older framework, don't think it is a breaking changes if the tool chain still need to keep net3, he could keep using the old version

dunham commented 3 years ago

Thanks for fixing this so fast! I see this should be in version 1.4.0 of the plugin, but I'm not seeing up on https://plugins.gradle.org/m2 yet. Is that in the works? Appreciate the work you've put into this!

ngyukman commented 3 years ago

Sorry the azure pipeline was breaking because of ubuntu-latest is still not yet having dotnet core 5 setup Didn't have time to confirm locally previously, now 1.4.0 should be ready, please help to try it, thanks

dunham commented 3 years ago

No worries, it's up now and working great. Thank you much!