Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlist GitVersionTask 5.1.3 ? #2125

Closed
dazinator opened this issue Feb 22, 2020 · 37 comments
Closed

Unlist GitVersionTask 5.1.3 ? #2125

dazinator opened this issue Feb 22, 2020 · 37 comments

Comments

@dazinator
Copy link
Member

dazinator commented Feb 22, 2020

GitVersionTask 5.1.3 has a pretty serious bug that breaks appveyor builds. I appreciate this won't necessarily impact other build systems, but given that AppVeyor it s pretty common one, it might be a good idea to unlist GitVersionTask 5.1.3 on nuget so people updating to latest stable (like I just have) don't end up hitting this issue. At the moment we have yet to release a fixed version (5.1.4) so 5.1.3 is the latest stable version on NuGet.

Here is a build showing the newtonsoft problem: https://ci.appveyor.com/project/dazinator/dotnet-glob/builds/30988507#L294

@dazinator dazinator changed the title Unlist GitVersionTask 5.1.3 Unlist GitVersionTask 5.1.3 ? Feb 22, 2020
@dazinator
Copy link
Member Author

@arturcic is this something you have the ability to do?

@arturcic
Copy link
Member

@dazinator I'm planning to release tomorrow or on Monday version 5.1.4

@dazinator
Copy link
Member Author

Ah ok. Probably for th ebest because even after downgrading to 5.1.2 of gitversiontask - that just gives me a different bug with a locked file: https://ci.appveyor.com/project/dazinator/dotnet-glob/builds/30988665 !

Fingers crossed for 5.1.4 haha

@dazinator
Copy link
Member Author

Hmm.. building locally with GitVersionTask 5.1.4-beta1.177 nuget package added to my csproj results in lots of errors:

Severity Code Description Project File Line Suppression State
Error MSB4062 The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\DarrellTunnell.nuget\packages\gitversiontask\5.1.4-beta1.177\build..\tools\net472\GitVersionTask.MsBuild.dll. Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the 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. DotNet.Glob.Benchmarks C:\Users\DarrellTunnell.nuget\packages\gitversiontask\5.1.4-beta1.177\build\GitVersionTask.targets 10

If this is going to be released tomorrow as 5.1.4 - i'm a little worries :-/
Is there something special I need to do to get this version of GitVersionTask working if I just installed it to a csproj?

@arturcic
Copy link
Member

I think that is because of this c602fbb

@arturcic
Copy link
Member

I can revert it and if you can check it's working

@dazinator
Copy link
Member Author

ah right! Ok yeah sure

@arturcic
Copy link
Member

Pushed, when it's ready would you mind checking the version and confirm it is fixed?

@dazinator
Copy link
Member Author

Ok, will do

@dazinator
Copy link
Member Author

waiting for a nuget package to appear for this build: 5.1.4-beta.1+179
has it definitely been pushed to nuget or the appveyor internal nuget feed yeah?

@arturcic
Copy link
Member

It's pushed to nuget.org and I guess to AppVeyor as well

@dazinator
Copy link
Member Author

The appveyor feed is usually pretty quick at showing the new package, so just thought it was odd that its not there. I know Nuget,org can take a while haha

@dazinator
Copy link
Member Author

Ok its appeared on nuget.org

@dazinator
Copy link
Member Author

Nope with this version I get a different error:

Severity Code Description Project File Line Suppression State
Error FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
at GitVersion.MSBuildTask.GitVersionTasks.BuildServiceProvider(GitVersionTaskBase task)
at GitVersion.MSBuildTask.GitVersionTasks.ExecuteGitVersionTask[T](T task, Action`1 action) in D:\a\GitVersion\GitVersion\src\GitVersionTask\GitVersionTasks.cs:line 25
DotNet.Glob C:\Users\DarrellTunnell.nuget\packages\gitversiontask\4.0.1-beta1-65\build\functionality\GitVersionMultiTargetBuild.targets 6

My project (DotNet.Glob) supports a large array of target frameworks like so:

<TargetFrameworks>netstandard1.1;netstandard2.1;netcoreapp2.1;net45;net46;net4</TargetFrameworks>

Previously I was using GitVersionTask 4.0.1-beta1-65 just fine.

<PackageReference Include="GitVersionTask" Version="4.0.1-beta1-65">
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>    

However all of a sudden, the AppVeyor build starting breaking: https://ci.appveyor.com/project/dazinator/dotnet-glob/builds/30988139

I thought perhaps updating GitVersion to latest version would help, and thats why I am not attempting to this, but no avail yet.

As to why my builds have started failing with "4.0.1-beta1-65" - I can only assume there must be some AppVeyor image change which has introduced an issue that didn't exist before - or that somehow the commit history of my repository is now causing this bug to exhibit that didn't before.

Who knows, but perhaps this is an issue only local to my project.

@dazinator
Copy link
Member Author

dazinator commented Feb 22, 2020

In my AppVeyor build I am first doing an ordinary GitVersion.exe to set AppVeyor build number. This is the thing that started failing with recent AppVeyor builds when using 4.0.1-beta1-65. I was using the same version of GitVersionTask added to my csproj.

I'm going to try just upgrading GitVersion.exe to 5.1.3, and leaving the GitVersionTask added to my csproj at "4.0.1-beta1-65" and will see what then happens.

i.e AppVeyor.yml

install:
  - cmd: choco install gitversion.portable --version 5.1.3 -y

and

 <ItemGroup>
    <PackageReference Include="GitVersionTask" Version="4.0.1-beta1-65">
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>    
  </ItemGroup>

@arturcic
Copy link
Member

btw, now we also publish to GitHub Package Repository

@dazinator
Copy link
Member Author

dazinator commented Feb 22, 2020

Ok that worked: https://ci.appveyor.com/project/dazinator/dotnet-glob/builds/30989316

So I have to remain on GitVersionTask 4.0.1-beta1-65 for now. It seems GitVersionTask 5.X has some problems. I don't want to delve back into that rabbit hole either just now! :-)

@dazinator
Copy link
Member Author

dazinator commented Feb 22, 2020

@arturcic - right I did some digging and I have discovered the source of the problem.

GitVersionTask 5.1.4-beta1.177 (the one prior to your revert) does indeed work as long as you use a stable dotnet sdk like 3.1.101, or 3.0.100 to build it e.g:

{
  "sdk": {
    "version": "3.0.100"
  }
}

and

 <PackageReference Include="GitVersionTask" Version="5.1.4-beta1.177">
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>

In my case, I have dotnet sdk 3.1.200-preview-014883 installed (I think this must have been installed by VS - Prerelease channel update), and this causes the problem when I build from VS locally, as GitVersionTask can't resolve its desired MSBuild assembly. I just need to add a global.json to pin my sdk version for now.

I tested with beta.179 also but beta 179 definatelt seems broken. Even if I build that with a stable SDK i get this:

C:\Users\DarrellTunnell.nuget\packages\gitversiontask\5.1.4-beta1.179\build\GitVersionTask.targets(10,9): error MSB4062: The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\DarrellTunnell.nuget\packages\gitversiontask\5.1.4-beta1.179\build..\tools\netstandard2.0\GitVersionTask.MsBuild.dll. Assembly with same name is already loaded Confirm that the 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. [C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj]

So with that in mind, would you mind reverting your revert?

.. and sorry for the trouble!

@arturcic
Copy link
Member

sure

@arturcic
Copy link
Member

when the new build is ready, could you once again validate it's working with the global.json fix again?

@arturcic
Copy link
Member

@dazinator can you check 5.1.4-beta1.181?

@dazinator
Copy link
Member Author

Yep sure.

By the way the global.json seems to fix the issue for dotnet cli builds.
When building from inside VS, using VS 2019 Community Preview (16.5.0 Preview 2.0) -you get build errors still. This is because when you run from VS, VS is in control of the version of MSBuild assembly that is ultimately used. When GitVersionTask does it's stuff, as it's compiled against a specific MS Build package, it breaks when a version of MSBuild is loaded, that it isn't expecting. When building from dotnet cli, the version of msbuild associated with that version of the CLI is used. Therefore the easy way to replicate the same problem is to build a project that has GitVersionTask installed, with a version of the dotnet cli that uses a newer MSBuild version (i.e like a newer preview dotnet sdk version) because this basically causes the same thing as is happening from VS.

So there seems there will always be an issue for VS builds given the way things currently work, in that, GitVersionTask will only work with specific versions of VS, and if you upgrade your VS to a new preview that is using a newer MSBuild then GitVersionTask builds may start failing - even if you add a global.json.

To that end, we should probably document which versions of VS can be used with GitVersionTask for each stable release, and making it very clear that if you use newer versions of VS, your mileage may vary.

@arturcic
Copy link
Member

Do you think we need to include this in the release notes of the nuget package? or the one on GitHub

@dazinator
Copy link
Member Author

@dazinator can you check 5.1.4-beta1.181?

Tested with VS2019 Community Preview and also VS2019 Professional. Both fail with:

Severity Code Description Project File Line Suppression State
Error MSB4062 The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\DarrellTunnell.nuget\packages\gitversiontask\5.1.4-beta1.181\build..\tools\net472\GitVersionTask.MsBuild.dll. Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the 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. DotNet.Glob C:\Users\DarrellTunnell.nuget\packages\gitversiontask\5.1.4-beta1.181\build\GitVersionTask.targets 10

dotnet build succeeded when pinned.

@arturcic
Copy link
Member

Are there any options we can fix it in VS?

@dazinator
Copy link
Member Author

Do you think we need to include this in the release notes of the nuget package? or the one on GitHub

Yeah that would be handy. Or perhaps we link to a doc that has a matrix with GitVersionTask version and VS versions it runs in, which we could start maintaining as of the next release.

The problem is, it really requires us to test the GitVersionTask with various VS versions to achieve this - or perhaps, test GitVersionTask with various MSBuild versions.

I know that you can write tests that utilise a particular version of MSBuild so its faesilbe we could write tests for GitVersionTask that excercise it using a variety of MSBuild versions, known to be associated with particular VS versions, then we say if you are using a VS version that doesn't use one of the following MSBuild versions then your mileage may vary. Needs some thought.

@arturcic
Copy link
Member

Ok, when you have some ideas to share, please let us know. Do you think having this issue, we can release version 5.1.4?

@dazinator
Copy link
Member Author

dazinator commented Feb 22, 2020

Are there any options we can fix it in VS?

I don't think so, but there are some things we can try that might sort it. Like this loader error I pasted above, i've see things that mention if you implement your msbuild tasks by deriving from ITask instead of the base Task you can drop an ms build references and this fixes the problem.

So places like here: https://github.com/GitTools/GitVersion/blob/master/src/GitVersionTask.MsBuild/GitVersionTaskBase.cs#L6

Came accross that discussion here: dotnet/msbuild#2111

I am willing to give this a go. Where should i be branching from these days - do I just create a new branch from master and submit a PR? or is there a develop branch that I can't see for beta stuff?

@arturcic
Copy link
Member

I usually use my fork and submit a PR

@dazinator
Copy link
Member Author

@arturcic
Copy link
Member

you need dotnet format global tool and run it like
dotnet format --folder ./ --dry-run --check

@dazinator
Copy link
Member Author

dazinator commented Feb 22, 2020

geees... does github now have its own build system - what's going on here: https://github.com/GitTools/GitVersion/actions/runs/43623597/workflow

Not another one, pleaseeeee haha

@dazinator
Copy link
Member Author

One thing we could do to catch issues earlier..

We could add a check to the CI build that does an msbuild /t:build of a project that has GitVersionTask package included. I think I have seen a check that does a dotnet build within a container for this. Perhaps we can do the same thing but using a container with different versions of MSBuild installed.

Here is me reproducing this issue locally using msbuild:

msbuild /t:build
Microsoft (R) Build Engine version 16.5.0-preview-20059-01+86d9494e4 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 23/02/2020 00:50:06.
Project "C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" on node
1 (build target(s)).
Project "C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" (1) is b
uilding "C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" (1:2) on
 node 1 (Build target(s)).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the i
nput files.
C:\Users\DarrellTunnell\.nuget\packages\gitversiontask\5.2.0-task-msbuild-fixes1.332\build\GitVersionTask.targets(10,9)
: error MSB4062: The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\DarrellTunnell\.n
uget\packages\gitversiontask\5.2.0-task-msbuild-fixes1.332\build\..\tools\net472\GitVersionTask.MsBuild.dll. Could not
load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
 of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, t
hat the assembly and all its dependencies are available, and that the task contains a public class that implements Micr
osoft.Build.Framework.ITask. [C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.
Glob.csproj]
Done Building Project "C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.cs
proj" (Build target(s)) -- FAILED.

Project "C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" (1) is b
uilding "C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" (1:3) on
 node 1 (Build target(s)).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the i
nput files.
C:\Users\DarrellTunnell\.nuget\packages\gitversiontask\5.2.0-task-msbuild-fixes1.332\build\GitVersionTask.targets(10,9)
: error MSB4062: The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\DarrellTunnell\.n
uget\packages\gitversiontask\5.2.0-task-msbuild-fixes1.332\build\..\tools\net472\GitVersionTask.MsBuild.dll. Could not
load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
 of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, t
hat the assembly and all its dependencies are available, and that the task contains a public class that implements Micr
osoft.Build.Framework.ITask. [C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.
Glob.csproj]
Done Building Project "C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.cs
proj" (Build target(s)) -- FAILED.

Done Building Project "C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.cs
proj" (build target(s)) -- FAILED.


Build FAILED.

"C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" (build target) (
1) ->
"C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" (Build target) (
1:2) ->
(WriteVersionInfoToBuildLog target) ->
  C:\Users\DarrellTunnell\.nuget\packages\gitversiontask\5.2.0-task-msbuild-fixes1.332\build\GitVersionTask.targets(10,
9): error MSB4062: The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\DarrellTunnell\
.nuget\packages\gitversiontask\5.2.0-task-msbuild-fixes1.332\build\..\tools\net472\GitVersionTask.MsBuild.dll. Could no
t load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or o
ne of its dependencies. The system cannot find the file specified. 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 Mi
crosoft.Build.Framework.ITask. [C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNe
t.Glob.csproj]


"C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" (build target) (
1) ->
"C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNet.Glob.csproj" (Build target) (
1:3) ->
  C:\Users\DarrellTunnell\.nuget\packages\gitversiontask\5.2.0-task-msbuild-fixes1.332\build\GitVersionTask.targets(10,
9): error MSB4062: The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\DarrellTunnell\
.nuget\packages\gitversiontask\5.2.0-task-msbuild-fixes1.332\build\..\tools\net472\GitVersionTask.MsBuild.dll. Could no
t load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or o
ne of its dependencies. The system cannot find the file specified. 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 Mi
crosoft.Build.Framework.ITask. [C:\Users\DarrellTunnell\source\repos\Dotnet-glob-temp\DotNet.Glob\src\DotNet.Glob\DotNe
t.Glob.csproj]

    0 Warning(s)
    2 Error(s)

@dazinator
Copy link
Member Author

I haven't been able to get to the bottom of this error to do with being unable to load System.Runtime.Loader.
It's a problem that occurs for the .NET 472 build of GitVersionTask - and as thats full .NET framework, it shouldn't be using System.Runtime.Loader at all, it should just use Assembly.Load. So something is causing this dependency to try and load on full .net and I can't see what.

@jetersen
Copy link
Contributor

you need dotnet format global tool and run it like
dotnet format --folder ./ --dry-run --check

You can also run dotnet format --folder ./ and it will do the formatting for you :)

@dazinator
Copy link
Member Author

you need dotnet format global tool and run it like
dotnet format --folder ./ --dry-run --check

You can also run dotnet format --folder ./ and it will do the formatting for you :)

Yep - I figured that one out just before I was about to bother arturcic again.

@dazinator
Copy link
Member Author

Going to close this and create seperate issues for things I've found.

@arturcic arturcic modified the milestone: 5.2.0 Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants