当我在本地运行时,GitVersion 任务工作正常并运行。在 Azure DevOps 构建管道中,相同的脚本失败。我收到以下错误:
========================================
Version
========================================
Executing task: Version
INFO [04/03/19 20:23:54:54] Working directory: D:\a\1\s\PPIL
INFO [04/03/19 20:23:54:56] IsDynamicGitRepository: False
ERROR [04/03/19 20:23:54:60] An unexpected error occurred:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-15e1193': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary()
at LibGit2Sharp.Core.NativeMethods..cctor()
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.NativeMethods.git_buf_free(GitBuf buf)
at LibGit2Sharp.Core.Handles.GitBuf.Dispose()
at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever)
at LibGit2Sharp.Repository.Discover(String startingPath)
at GitVersion.GitPreparer.GetDotGitDirectory()
at GitVersion.GitPreparer.GetProjectRootDirectory()
at GitVersion.ConfigurationProvider.Verify(GitPreparer gitPreparer, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()
INFO [04/03/19 20:23:54:60]
INFO [04/03/19 20:23:54:60] Attempting to show the current git graph (please include in issue):
INFO [04/03/19 20:23:54:60] Showing max of 100 commits
INFO [04/03/19 20:23:54:64] * c27bbc5 5 minutes ago (HEAD, origin/master)
|\
| * 57526a4 11 minutes ago
|/
* 5057bd8 63 minutes ago
|\
| * 3df4426 68 minutes ago
|/
* 9e7d5bc 6 days ago
|\
| * 222a7e0 6 days ago
|/
* 3474e55 6 days ago
|\
| * 9156567 6 days ago
| * 043e8be 6 days ago
|/
| * d4394a6 2 days ago (origin/serilog)
|/
* 888471a 7 days ago
* 17c9ee3 2 weeks ago
|\
| * 9f61e42 2 weeks ago
| * 02e6828 2 weeks ago
| * 62dd884 3 weeks ago
|/
* b71f0e2 4 weeks ago
|\
| * a040103 4 weeks ago
| * 45a773c 4 weeks ago
|/
* 6ac1314 5 weeks ago
* 3f81960 5 weeks ago
* 8ea9f85 5 weeks ago
* c9bb4ee 5 weeks ago
INFO [04/03/19 20:23:54:54] Working directory: D:\a\1\s\PPIL
INFO [04/03/19 20:23:54:56] IsDynamicGitRepository: False
ERROR [04/03/19 20:23:54:60] An unexpected error occurred:
System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-15e1193': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary()
at LibGit2Sharp.Core.NativeMethods..cctor()
--- End of inner exception stack trace ---
at LibGit2Sharp.Core.NativeMethods.git_buf_free(GitBuf buf)
at LibGit2Sharp.Core.Handles.GitBuf.Dispose()
at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever)
at LibGit2Sharp.Repository.Discover(String startingPath)
at GitVersion.GitPreparer.GetDotGitDirectory()
at GitVersion.GitPreparer.GetProjectRootDirectory()
at GitVersion.ConfigurationProvider.Verify(GitPreparer gitPreparer, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()
INFO [04/03/19 20:23:54:60]
INFO [04/03/19 20:23:54:60] Attempting to show the current git graph (please include in issue):
INFO [04/03/19 20:23:54:60] Showing max of 100 commits
INFO [04/03/19 20:23:54:64] * c27bbc5 5 minutes ago (HEAD, origin/master)
|\
| * 57526a4 11 minutes ago
|/
* 5057bd8 63 minutes ago
|\
| * 3df4426 68 minutes ago
|/
* 9e7d5bc 6 days ago
|\
| * 222a7e0 6 days ago
|/
* 3474e55 6 days ago
|\
| * 9156567 6 days ago
| * 043e8be 6 days ago
|/
| * d4394a6 2 days ago (origin/serilog)
|/
* 888471a 7 days ago
* 17c9ee3 2 weeks ago
|\
| * 9f61e42 2 weeks ago
| * 02e6828 2 weeks ago
| * 62dd884 3 weeks ago
|/
* b71f0e2 4 weeks ago
|\
| * a040103 4 weeks ago
| * 45a773c 4 weeks ago
|/
* 6ac1314 5 weeks ago
* 3f81960 5 weeks ago
* 8ea9f85 5 weeks ago
* c9bb4ee 5 weeks ago
##[error]An error occurred when executing task 'Version'.
##[error]Error: One or more errors occurred.
##[error] GitVersion: Process returned an error (exit code 1).
##[error]System.Exception: Unexpected exit code 1 returned from tool Cake.exe
at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
##[error]PowerShell script completed with 1 errors.
##[section]Finishing: Integration Layer Cake
它似乎涉及不存在的LibGit2Sharp.Core.NativeMethods库。我认为如果我包含以下内容,Cake 项目会下载所需的 dll:
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
在 Cake 构建脚本中。
我的 GitVersion 任务代码是:
GitVersion versionInfo = null;
Task("Version")
.Does(() => {
GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.BuildServer
});
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });
Information("Version info: " + versionInfo.InformationalVersion);
});
我在 Azure DevOps 托管生成代理中未包含的代码中缺少什么?