MSBuild 中的 SharpSVN 错误

发布于 2024-12-03 10:10:26 字数 2385 浏览 0 评论 0原文

我有以下代码来使用 SharpSVN 从 Subversion 获取已更改文件的列表。

该代码在单元测试中工作得很好,但在从 MSBuild 运行时失败。单元测试和 MSBuild 都使用相同的参数运行(我已通过调试两者进行检查),并且在同一用户下运行。错误异常在 GetLog 内部引发,(GetInfo 成功,其他 SVN 方法在其他地方工作)。

有什么想法吗?

代码:

public IEnumerable<string> GetChangedFiles(long revisionNumber)
{
    using (var client = new SvnClient())
    {
        SvnInfoEventArgs info;
        client.GetInfo(_workingCopyPath, out info);
        var lastRevision = info.LastChangeRevision;

        Collection<SvnLogEventArgs> logItems;
        var args = new SvnLogArgs();
        args.RetrieveChangedPaths = true;
        if (revisionNumber > lastRevision)
        {
            throw new ArgumentException(string.Format(
               "Revision number ({0}) is greater than last revision ({1})",
               revisionNumber, lastRevision));
        }

        args.Range = new SvnRevisionRange(revisionNumber, lastRevision);
        client.GetLog(_workingCopyPath, args, out logItems);
        return logItems.SelectMany(li => li.ChangedPaths).Select(cp => cp.Path);
    }
}

和例外:

System.Runtime.InteropServices.SEHException was unhandled by user code
  Message=External component has thrown an exception.
  Source=SharpSvn
  ErrorCode=-2147467259
  StackTrace:
       at svn_client_log5(apr_array_header_t* , svn_opt_revision_t* , apr_array_header_t* , Int32 , Int32 , Int32 , Int32 , apr_array_header_t* , IntPtr , Void* , svn_client_ctx_t* , apr_pool_t* )
       at SharpSvn.SvnClient.InternalLog(ICollection`1 targets, Uri logRoot, SvnRevision altPegRev, SvnLogArgs args, EventHandler`1 logHandler)
       at SharpSvn.SvnClient.Log(String targetPath, SvnLogArgs args, EventHandler`1 logHandler)
       at SharpSvn.SvnClient.GetLog(String targetPath, SvnLogArgs args, Collection`1& logItems)
       at MSBuild.CustomTasks.SVN.Svn.GetChangedFiles(Int64 revisionNumber)
       at MSBuild.CustomTasks.SVN.SvnCopy.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
  InnerException: 

I have the following code to get a list of changed files from Subversion using SharpSVN.

The code works perfectly fine from unit tests but fails when run from MSBuild. Both unit test and MSBuild are run using the same parameters (I've checked by debugging both), and are run under the same user. The error exception is raised inside GetLog, (GetInfo succeeds, and other SVN methods work else where).

Any ideas?

Code:

public IEnumerable<string> GetChangedFiles(long revisionNumber)
{
    using (var client = new SvnClient())
    {
        SvnInfoEventArgs info;
        client.GetInfo(_workingCopyPath, out info);
        var lastRevision = info.LastChangeRevision;

        Collection<SvnLogEventArgs> logItems;
        var args = new SvnLogArgs();
        args.RetrieveChangedPaths = true;
        if (revisionNumber > lastRevision)
        {
            throw new ArgumentException(string.Format(
               "Revision number ({0}) is greater than last revision ({1})",
               revisionNumber, lastRevision));
        }

        args.Range = new SvnRevisionRange(revisionNumber, lastRevision);
        client.GetLog(_workingCopyPath, args, out logItems);
        return logItems.SelectMany(li => li.ChangedPaths).Select(cp => cp.Path);
    }
}

And the exception:

System.Runtime.InteropServices.SEHException was unhandled by user code
  Message=External component has thrown an exception.
  Source=SharpSvn
  ErrorCode=-2147467259
  StackTrace:
       at svn_client_log5(apr_array_header_t* , svn_opt_revision_t* , apr_array_header_t* , Int32 , Int32 , Int32 , Int32 , apr_array_header_t* , IntPtr , Void* , svn_client_ctx_t* , apr_pool_t* )
       at SharpSvn.SvnClient.InternalLog(ICollection`1 targets, Uri logRoot, SvnRevision altPegRev, SvnLogArgs args, EventHandler`1 logHandler)
       at SharpSvn.SvnClient.Log(String targetPath, SvnLogArgs args, EventHandler`1 logHandler)
       at SharpSvn.SvnClient.GetLog(String targetPath, SvnLogArgs args, Collection`1& logItems)
       at MSBuild.CustomTasks.SVN.Svn.GetChangedFiles(Int64 revisionNumber)
       at MSBuild.CustomTasks.SVN.SvnCopy.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
  InnerException: 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏尔 2024-12-10 10:10:26

我找到了解决方案,但它非常适合我的情况。

当我部署 CustomTask 时,我忘记部署 SharpSvn-SASL21-23-Win32.dll (从单元测试运行时它就在那里)。

I found the solution, it was quite specific to my case though.

When I deployed my CustomTask I forgot to deploy SharpSvn-SASL21-23-Win32.dll (it was there when run from the unit test).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文