具有依赖项的自定义MSBuild任务 [英] Custom MSBuild task with dependencies

查看:142
本文介绍了具有依赖项的自定义MSBuild任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个使用第三方程序集的MSBuild任务.

I have written an MSBuild task that makes use of third-party assemblies.

当我在项目中使用任务时,MSBuild抱怨它无法加载第三方程序集(不足为奇).

When I use the task in my project, MSBuild complains that it can't load the third-party assemblies (not surprisingly).

我应该在哪里放置第三方程序集,以便MSBuild可以使用它们.我尝试向他们添加项目引用,但是没有成功.

Where should I place the third-party assemblies so that they are available to MSBuild. I tried adding project references to them without success.

推荐答案

我不确定我是否很好地表达了我的问题,但是现在我找到了解决方法.

I'm not sure if I expressed my problem very well, but now I've found the solution.

在我的.proj文件中,我使用以下语法引用了自定义任务...

In my .proj file, I reference my custom task with the following syntax...

<UsingTask AssemblyFile="..\lib\MyCompany.MSBuild\MyCompany.MSBuild.dll" TaskName="CreateDatabase" />

我的CreateDatabase任务依赖于各种第三方程序集.但是,其中一些仅通过反射引用,因此默认情况下未包含在文件夹".. \ lib \ MyCompany.MSBuild"中.

My CreateDatabase task relies on various 3rd-party assemblies. However, some of these are only referenced via reflection, so weren't included by default in the folder "..\lib\MyCompany.MSBuild".

我一直试图通过将所需的程序集放在与调用任务的.proj文件相同的目录中来使任务正常工作.

I had been trying to get the task to work by placing the required assemblies in the same directory as the .proj file invoking the task.

但是,我应该做的是将程序集放在引用的任务目录".. \ lib \ MyCompany.MSBuild \"中.

However, what I should have been doing was putting the assemblies in the referenced task directory "..\lib\MyCompany.MSBuild\".

简单!

这篇关于具有依赖项的自定义MSBuild任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆