使用自定义任务(UsingTask)时,如何使msbuild查找.Net程序集. [英] How do I make msbuild find .Net assemblies when using a custom task (UsingTask)>

查看:249
本文介绍了使用自定义任务(UsingTask)时,如何使msbuild查找.Net程序集.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经基于旧的CodePlex项目构建了一个自定义msbuild任务:

I've built a custom msbuild task based on the old CodePlex project:

http://sqlsrvintegrationsrv .codeplex.com/SourceControl/latest#main/SSISMSBuild/Project/Microsoft.SqlServer.IntegrationServices.Build.csproj

最终使它能够在VS 2015中构建(使用SQL Server 2016 SMSS程序集)之后,我可以使用已编译的项目DLL来构建SSIS项目.

After finally getting this to build in VS 2015 (using the SQL Server 2016 SMSS assemblies) I can use the compiled project DLL to build SSIS projects.

但是,我只能构建SSIS项目(例如,使用项目文件,例如 https://speaksql.wordpress.com/2013/06/07/a-journey-to-db-deployment-automaton- ssis-build-using-msbuild/),当我将程序集(自定义任务DLL和SMSS的依赖项)复制到msbuild bin目录的副本中时.

However, I can only get the SSIS project to build (e.g. using a project file such as at https://speaksql.wordpress.com/2013/06/07/a-journey-to-db-deployment-automaton-ssis-build-using-msbuild/) when I copy the assemblies (the custom task DLL and the dependences from SMSS) into a copy of the msbuild bin directory.

是否有任何方法可以指示Msbuild在特定路径下查找?如果可能的话,我宁愿不将汇编添加到GAC.

Is there any way to direct Msbuild to look in a specific path? I'd rather not add assembles to the GAC if possible.

我已经阅读了所有Web文章和帖子,但是它们主要涉及C#.csproj项目,并且涉及设置AssemblySearchPaths和ReferencePath.因为这不是C#项目文件,所以我不能使用它们.

I've read any web articles and posts but they mostly refer to C# .csproj projects and they refer to setting AssemblySearchPaths and ReferencePath. As this isn't a C# project file I can't use these.

此问题仅发生在我的一台计算机上(Windows Server 2012).在Windows 10机器上似乎一切正常:(

This issue is only occurring on one of my machines (Windows Server 2012). Thing seem to work fine on my Windows 10 machine :(

我可以看到其他人也看到了这个问题.例如.:- MsBuild看起来不在自定义任务第二级依赖项的好目录中

I can see other people have also seen this issue. E.g.:- MsBuild does not look in the good directory for custom task's second-level dependencies

任何帮助将不胜感激!

推荐答案

<UsingTask>指令的AssemblyFile属性允许您指定要加载的程序集的完整路径.

The <UsingTask> directive's AssemblyFile attribute allows you to specify the full path to the assembly you want to load.

通常相对于要使用特定任务的文件的位置来完成此操作.例如如果构建包含任务的NuGet软件包,通常将具有build/{packageId}.targets文件,例如,包含所需任务的tools/net46/sometasks.dll文件. .targets文件将使用:

This is usually done relative to the location of the file that wants to use a particular task. e.g. if you build a NuGet package that contains a task, you would usually have a build/{packageId}.targets file and for example an tools/net46/sometasks.dll that contains the needed tasks. The .targets file would then use:

<UsingTask TaskName="MyCustomTask" AssemblyFile="$(MSBuildThisFileDirectory)..\tools\net46\sometasks.dll" />

如果任务dll也引用了其他程序集,则它们必须与该程序集位于同一目录中才能被发现.

If the task dll also references other assemblies, they need to be located in the same directory as the assembly in order to be discovered.

这篇关于使用自定义任务(UsingTask)时,如何使msbuild查找.Net程序集.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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