MSBuild 中的 SharpSVN 错误
我有以下代码来使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案,但它非常适合我的情况。
当我部署 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).