MSBuild Inline Task - Reference non-standard Microsoft assemblies

六眼飞鱼酱① 提交于 2019-11-30 17:27:28

I would still like a real answer to this, but I was able to workaround this issue using reflection and just loading the assembly.

You can see the full source in my gist.

According to this article in Dzone: Web.config transformations you must add

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>

just in the head of MSBuild file. It seems that MSBuild does not find it and trying to load from GAC

Herman

Another work around is using AppDomain.AssemblyResolve. However, you will then have to register your handler before the framework needs the assembly.

This can be done by putting everything in an Action delegate inside the fragment. Another possibility is setting the 'Type' attribute of the 'Code' element to 'class' instead of 'fragment'.

For information about using AssemblyResolve there is already an article on stackoverflow: How to add folder to assembly search path at runtime in .NET?.

Still not ideal, but in my case cleaner than reflection.

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