How to solve: Custom MSBuild task requires assembly outside of AppBase

◇◆丶佛笑我妖孽 提交于 2019-12-05 06:16:27

So copy it instead? Just a thought. Have a copy there just to support the build that you delete once you're done with it.

I see multiple solutions :

1st : Add the assembly in the GAC (your assembly must have a strong name)

gacutil /I <assembly name> 

2nd : Locate the assembly through Codebases or Probing, in your machine.config file or in msbuild.exe.config .

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
            <assemblyIdentity name="MyCommon"
                              publicKeyToken="32ab4ba45e0a69a1"
                              culture="neutral" />
            <codeBase version="2.0.0.0"
                      href="file://C:/yourpath/MyCommon.DLL"/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

3rd : copy the assembly in the same directory before and delete it after, like David M said.

An option is to use ILMerge to merge the dependency into the task assembly.

All of these "solutions" create more dependencies which complicate the environment. There should be an easier way to update the probing path at runtime..

Specifically MSBuild should allow you to add probing paths in your .proj file, or to specify the dependant dlls

You can define a custom UsingTask:

<UsingTask TaskName="Task" AssemblyFile="Assembly.dll" />

but you cant add dependencies? it should be included... here with something like

<UsingTask TaskName="Task" AssemblyFile="Assembly.dll">
<DependantAssembly AssemblyFile="dependant.dll"/>
</UsingTask>

But, no this isn't supported...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!