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

dotnet build command always fails with GitVersionTask 4.0.0-beta #1399

Closed
walterlv opened this issue Apr 12, 2018 · 15 comments
Closed

dotnet build command always fails with GitVersionTask 4.0.0-beta #1399

walterlv opened this issue Apr 12, 2018 · 15 comments

Comments

@walterlv
Copy link

walterlv commented Apr 12, 2018

When a totally new .NET Standard project is created and GitVersionTask is installed on it, dotnet build command certainly fails with this message below:

C:\Users\walterlv.nuget\packages\gitversiontask\4.0.0-beta0012\build\GitVersionTask.targets(49,5): error MSB4062: The "GitVersionTask.WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\walterlv.nuget\packages\gitversiontask\4.0.0-beta0012\build\GitVersionTask.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'. 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. [C:\Users\walterlv\Desktop\XxxYyyZzz\XxxYyyZzz\XxxYyyZzz.csproj]

The raw error message is here:

> dotnet build
Microsoft (R) Build Engine version 15.6.84.34536 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 42.12 ms for C:\Users\walterlv\Desktop\XxxYyyZzz\XxxYyyZzz\XxxYyyZzz.csproj.
C:\Users\walterlv\.nuget\packages\gitversiontask\4.0.0-beta0012\build\GitVersionTask.targets(49,5): error MSB4062: The "GitVersionTask.WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\walterlv\.nuget\packages\gitversiontask\4.0.0-beta0012\build\GitVersionTask.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'. 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 Microsoft.Build.Framework.ITask. [C:\Users\walterlv\Desktop\XxxYyyZzz\XxxYyyZzz\XxxYyyZzz.csproj]

Build FAILED.

C:\Users\walterlv\.nuget\packages\gitversiontask\4.0.0-beta0012\build\GitVersionTask.targets(49,5): error MSB4062: The "GitVersionTask.WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\walterlv\.nuget\packages\gitversiontask\4.0.0-beta0012\build\GitVersionTask.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'. 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 Microsoft.Build.Framework.ITask. [C:\Users\walterlv\Desktop\XxxYyyZzz\XxxYyyZzz\XxxYyyZzz.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.40

Fortunately, if I build it using msbuild.exe or Visual Studio 2017, it succeeds.

My environment:

  • Windows 10.0.16299.371
  • Visual Studio 2017 (15.6.6)
@walterlv
Copy link
Author

walterlv commented Apr 12, 2018

I found some related issues from other repositories:

It seems that we should change our way to write UsingTask following .NET Core MSBuild hint.

That means we should multitargeting the GitVersionTask assembly to a version of .net standard / .net core and .net framework and then use a different assembly based on $(MSBuildRuntimeType). See dotnet/msbuild#2111 and read comments of @dasMulli for more details.

@elestedt
Copy link

Is there a workaround or must I look for another library if I've run into this? I'm going to build it CLI in a docker container in my CI environment and msbuild does not exist there

@dazinator
Copy link
Member

What version of dotnet sdk are you building under? Please add a global.json file to lock to sdk version 2.0.0 or below. Support for building under > 2 has not bren merged yet. Please also try latest beta15 package from appveyor project nuget feed or failing that, beta14 from nuget.org

@dazinator
Copy link
Member

P.s we do multitarget and you should see netstandard1.5 compiled gitversiontask assembly in the nuget package.

@walterlv
Copy link
Author

@dazinator This issue was posted four months ago and .NET Core 2.0 was the latest version at that time. Maybe I can try the newest version now.

@dazinator
Copy link
Member

dazinator commented Aug 29, 2018

@walterlv Sure. I think there is still an issue at present though when using the latest update of VS2017 (15.8.X). I uninstalled VS2017 15.8.2 and installed VS2017 15.7.6 and that seems to work. Also regardless of VS Version, dotnet build works for me as long as its pinned to SDK version 2.0 with a global.json. I have just created an issue using VS's send feedback to report the VS issue. Also I have reported here in case its a utilpack thing: stazz/UtilPack#30

@walterlv
Copy link
Author

@dazinator Actually, it's not the bug of MSBuild or Visual Studio. I've written my own NuGet package which is used to generate git version and it works both on MSBuild and dotnet build.

@walterlv
Copy link
Author

@dazinator I've tested the latest versions of Visual Studio, .NET Core and GitVersionTask, and I find all works fine. Maybe I can close this issue.

@lindexi
Copy link

lindexi commented Aug 29, 2018

@walterlv It's Chinese blog.

@dazinator
Copy link
Member

dazinator commented Aug 29, 2018

@walterlv

and it works both on MSBuild and dotnet build

Have you tried building from within VS 2017 (version 15.8.2) ?

  • The issue we are seeing at ArgumentNullException in node issue with beta0014 #1458 only seems to occur when building with VS 2017 Community version 15.8.X. When building from msbuild on the command line, or from dotnet build on the command line it works. Are you saying you can build also fine from within VS 2017? If so would you mind confirming what version of VS2017 you are using to build with? Thanks

@walterlv
Copy link
Author

@dazinator
Mine: 15.8.1
It works fine, too.

@dazinator
Copy link
Member

@walterlv ok thanks for confirming. I think we can close this one then. If you do ever update VS to 15.8.2 and it starts failing (or not) please drop a comment on #1458 to let us know :-) Thanks

@walterlv
Copy link
Author

@dazinator OK!

@dazinator
Copy link
Member

@walterlv when you build from vs2017 15.8.1 - did you check the "output" tab in.VS for an error - because the error only seems to show up there, it does not show up on the build errors tab so that might lead you to think gitversiontask ran successfully from VS when it didn't.

@walterlv
Copy link
Author

walterlv commented Aug 29, 2018

@dazinator I've updated to vs 2017 15.8.2 and the build still succeeds but with a warning.

Microsoft Visual Studio Professional 2017
Version 15.8.2
© 2017 Microsoft Corporation.
All rights reserved.

1>------ Rebuild All started: Project: CovulisGatarTeani, Configuration: Debug Any CPU ------
1>C:\Users\lvyi\Desktop\CovulisGatarTeani\CovulisGatarTeani\CovulisGatarTeani.csproj : warning NU1701: Package 'GitVersion 4.0.0-beta0012' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.
1>CovulisGatarTeani -> C:\Users\lvyi\Desktop\CovulisGatarTeani\CovulisGatarTeani\bin\Debug\netcoreapp2.1\CovulisGatarTeani.dll
1>Done building project "CovulisGatarTeani.csproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="GitVersion" Version="4.0.0-beta0012" />
  </ItemGroup>
</Project>

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

4 participants