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]
same here.
Same problem without multitargeting, only netcoreapp22/netstandard20
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.
Still no fix?
I have this problem on 4.0.0, but not on 4.0.0-beta0012
Can you guys give it a try to this version
As LibGit2Sharp was upgraded to version 0.26 in #1713, I think this problem is fixed. Please reopen this issue if the problem persists.
@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.
Gave you followed these steps? https://gitversion.readthedocs.io/en/latest/usage/msbuild-task/, the Remove AssemblyInfo attributes step I mean
I guess in your case it's an sdk project, then you should add this
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Thanks for the pointer. In the past it worked without that property. I'll try it tomorrow.
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.
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?
same issue on dot net core 3 project
Most helpful comment
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.