axlj45 / dotnet-semantic-release

MIT License
13 stars 4 forks source link

TargetInvocationException #2

Open bvirkler opened 4 years ago

bvirkler commented 4 years ago

I'm getting a TargetInvocationException while executing semantic-release project-version.

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "C:\Program Files\dotnet\sdk\3.0.100\15.0\Microsoft.Common.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props

I'm getting this in an Azure DevOps Pipeline as well as on my local machine. Locally, I can see that I do not have a C:\Program Files\dotnet\sdk\3.0.100\15.0 directory - Microsoft.Common.props is instead located in C:\Program Files\dotnet\sdk\3.0.100\Current.

bvirkler commented 4 years ago

Full stack trace: https://gist.github.com/bvirkler/817f47e4f87bcdd3f8aa7c305d3a7254

bvirkler commented 4 years ago

Cloning this project and upgrading Microsoft.Build and Microsoft.Build.Utilities.Core to 16.4.0 fixed this for me.
An alternative to add flexibility might be to use MSBuildLocator. MSBuildLocator cannot be used in .NET Standard projects though; you would have to target .NET Core instead. Unless I'm mistaken, some of the code is already specific to .NET Core, so maybe that's a possibility?