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

4.0.1-beta1-58: dotnet build crashes with error MSB4044: The "GetAssemblyVersion" task was not given a value for the required parameter "NuGetVersion" #1557

Closed
wjrogers opened this issue Dec 21, 2018 · 17 comments

Comments

@wjrogers
Copy link
Contributor

My project is multi-targeting net471 and netcoreapp2.1. The same error occurs when I build both targets and when I build either one individually.

There is a mismatch between SDK NuGet version (4.9.2) and the NuGet version the task factory was compiled against (4.9.0).
[NuGet Minimal]: Restoring packages for C:\Users\will\.nuget\packages\gitversiontask\4.0.1-beta1-58\build\functionality\GitVersionBuild.targets...
[NuGet Minimal]: Restoring packages for C:\Users\will\.nuget\packages\gitversiontask\4.0.1-beta1-58\build\functionality\GitVersionBuild.targets...
There is a mismatch between SDK NuGet version (4.9.2) and the NuGet version the task factory was compiled against (4.9.0).
MSBUILD : warning : WARN [12/21/18 11:25:46:12] Could not determine assembly version: System.Runtime.InteropServices.MarshalDirectiveException: StrictFilePathMarshaler must be used on a FilePath. [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.StrictFilePathMarshaler.MarshalManagedToNative(Object managedObj) in C:\projects\libgit2sharp\LibGit2Sharp\Core\FilePathMarshaler.cs:line 71 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome) [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.NativeMethods.git_repository_discover(GitBuf buf, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs) [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 3553 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at LibGit2Sharp.Repository.Discover(String startingPath) in C:\projects\libgit2sharp\LibGit2Sharp\Repository.cs:line 645 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory() in C:\projects\gitversion\src\GitVersionCore\GitPreparer.cs:line 163 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 33 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 82 [C:\Work\Redacted\Redacted\Redacted.csproj]
There is a mismatch between SDK NuGet version (4.9.2) and the NuGet version the task factory was compiled against (4.9.0).
MSBUILD : warning : WARN [12/21/18 11:25:46:20] Could not determine assembly version: System.Runtime.InteropServices.MarshalDirectiveException: StrictFilePathMarshaler must be used on a FilePath. [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.StrictFilePathMarshaler.MarshalManagedToNative(Object managedObj) in C:\projects\libgit2sharp\LibGit2Sharp\Core\FilePathMarshaler.cs:line 71 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome) [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.NativeMethods.git_repository_discover(GitBuf buf, FilePath start_path, Boolean across_fs, FilePath ceiling_dirs) [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 3553 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at LibGit2Sharp.Repository.Discover(String startingPath) in C:\projects\libgit2sharp\LibGit2Sharp\Repository.cs:line 645 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at GitVersion.GitPreparer.GetDotGitDirectory() in C:\projects\gitversion\src\GitVersionCore\GitPreparer.cs:line 163 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 33 [C:\Work\Redacted\Redacted\Redacted.csproj]
MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication) in C:\projects\gitversion\src\GitVersionCore\ExecuteCore.cs:line 82 [C:\Work\Redacted\Redacted\Redacted.csproj]
C:\Program Files\dotnet\sdk\2.1.502\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.GenerateAssemblyInfo.targets(161,5): error MSB4044: The "GetAssemblyVersion" task was not given a value for the required parameter "NuGetVersion". [C:\Work\Redacted\Redacted\Redacted.csproj]
@bonesoul
Copy link

bonesoul commented Jan 3, 2019

same here.

@twsl
Copy link

twsl commented Jan 12, 2019

Same problem without multitargeting, only netcoreapp22/netstandard20

@rafamerlin
Copy link

rafamerlin commented Jan 17, 2019

Hey guys, had the same issue, but on version 4.0.0 (not the beta). The reason was I had just created a new project and added Gitversion without ever committing anything to the project. After I created my first commit the issue stopped happening.

Possibly not the same issue though.

@twsl
Copy link

twsl commented Feb 5, 2019

Still no fix?

@thestonehead
Copy link

I have this problem on 4.0.0, but not on 4.0.0-beta0012

@arturcic
Copy link
Member

Can you guys give it a try to this version

@arturcic
Copy link
Member

As LibGit2Sharp was upgraded to version 0.26 in #1713, I think this problem is fixed. Please reopen this issue if the problem persists.

@thoemmi
Copy link
Contributor

thoemmi commented Jun 27, 2019

@arturcic The original bug is fixed, thanks. However, it seems like beta4 introduced a new issue: GitVersionTool generates multiple assembly version files.

In obj/Debug/<target framework>/ there are three(!) files with AssemblyFileVersion generated. E.g. AssemblyInfo_TinyLittleMvvm_luhkzhpu.hpc.g.cs, AssemblyInfo_TinyLittleMvvm_vldmbkmg.upl.g.cs, and TinyLittleMvvm.AssemblyInfo.cs. The first two files contain only the attributes AssemblyFileVersion, AssemblyVersion, and AssemblyInformationalVersion, and the last file contains all assembly level attributes.

This results in many error CS0579: Duplicate 'System.Reflection.AssemblyXxxAttribute' attribute errors. E.g. see the output of my latest build.

@arturcic
Copy link
Member

Gave you followed these steps? https://gitversion.readthedocs.io/en/latest/usage/msbuild-task/, the Remove AssemblyInfo attributes step I mean

@arturcic
Copy link
Member

I guess in your case it's an sdk project, then you should add this
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

@thoemmi
Copy link
Contributor

thoemmi commented Jun 27, 2019

Thanks for the pointer. In the past it worked without that property. I'll try it tomorrow.

@thoemmi
Copy link
Contributor

thoemmi commented Jun 28, 2019

Well, the GenerateAssemblyInfo indeed disables generating the AssemblyInfo. However, that file also includes all the assembly attributes, such as AssemblyProduct, AssemblyTitle, AssemblyCopyright and so forth.

The correct way is to set <UpdateAssemblyInfo>false</UpdateAssemblyInfo>. In this case, GitVersion won't generate its own AssemblyInfo file, but set the necessary MSBuild properties, and the SDK build will write the correct values to its AssemblyInfo.

@Mexicoder
Copy link

I'm still having this issue with my .net core 2.2 web project. i have tried the steps suggested but still getting the same error. Any other suggestions?

@bonesoul
Copy link

same issue on dot net core 3 project

@jmevel
Copy link

jmevel commented Jul 21, 2021

Hey guys, had the same issue, but on version 4.0.0 (not the beta). The reason was I had just created a new project and added Gitversion without ever committing anything to the project. After I created my first commit the issue stopped happening.

Possibly not the same issue though.

This helped me a lot.
In my case this was because I checked out a specific commit in git.
I just created a new branch on this commit and the issue disappeared

@MolotovCherry
Copy link

MolotovCherry commented Nov 18, 2023

For anyone coming from Google, this was near impossible for me to track down, but it turned out it was simply because all the source files in my project were LF instead of CRLF.

Which was the reason why it sometimes worked when doing different git things like git branching, git stashing, etc, but kept re-appearing randomly for some inexplicable reason

@deadlydog
Copy link

For others coming here because they searched the error message

The "GetAssemblyVersion" task was not given a value for the required parameter "NuGetVersion"

for me the problem was I was only specifying the Version parameter in my build script, and needed to specify the AssemblyVersion as well.

That is, I changed this:

dotnet build "$path" -p:Version=$versionNumber --configuration Release

Which would give the error, to this:

dotnet build "$path" -p:AssemblyVersion=$versionNumber -p:Version=$versionNumber --configuration Release

And that fixed it up for me.

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