运行 时,Cake Build 脚本中的 GitVersion 任务在 Azure DevOps 上缺少库
GitVersion task in Cake Build script is missing library on Azure DevOps when run
当我在本地 运行 时,GitVersion 任务工作正常并且 运行s。在 Azure DevOps 构建管道中,相同的脚本失败。我收到以下错误:
========================================
Version
========================================
Executing task: Version
INFO [04/03/19 20:23:54:54] Working directory: D:\a\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\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 托管生成代理中未包含的代码中缺少什么?
所以我想通了这个问题。我有一个 .gitignore 文件,它从 git 提交中删除了 x86 和 x64 文件夹。那么,GitVersion 命令行工具的 Windows dll 文件位于 win32 文件夹下的那些命名文件夹中。因此,该工具及其所有子文件夹都提交给了 repo,除了那些 dll,因此当 cake 运行 时,它认为该工具在那里,但 dll 丢失了。我手动强制提交这些 dll 及其文件夹,这解决了它。
我真正应该做的是删除,然后 .git忽略工具目录中包含 cake build 及其工具的所有文件,packages.config 文件除外,这样每次我们运行 自动构建它应该得到蛋糕和工具的新副本。但这是一个设计决定。
明智的警告,如果您缺少 dll 或文件,请检查 git忽略文件是否删除了这些文件 and/or 它的任何父文件夹。
当我在本地 运行 时,GitVersion 任务工作正常并且 运行s。在 Azure DevOps 构建管道中,相同的脚本失败。我收到以下错误:
========================================
Version
========================================
Executing task: Version
INFO [04/03/19 20:23:54:54] Working directory: D:\a\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\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 托管生成代理中未包含的代码中缺少什么?
所以我想通了这个问题。我有一个 .gitignore 文件,它从 git 提交中删除了 x86 和 x64 文件夹。那么,GitVersion 命令行工具的 Windows dll 文件位于 win32 文件夹下的那些命名文件夹中。因此,该工具及其所有子文件夹都提交给了 repo,除了那些 dll,因此当 cake 运行 时,它认为该工具在那里,但 dll 丢失了。我手动强制提交这些 dll 及其文件夹,这解决了它。
我真正应该做的是删除,然后 .git忽略工具目录中包含 cake build 及其工具的所有文件,packages.config 文件除外,这样每次我们运行 自动构建它应该得到蛋糕和工具的新副本。但这是一个设计决定。
明智的警告,如果您缺少 dll 或文件,请检查 git忽略文件是否删除了这些文件 and/or 它的任何父文件夹。