gpt4 book ai didi

c# - MSBuild 内联任务 - 引用非标准 Microsoft 程序集

转载 作者:可可西里 更新时间:2023-11-01 07:48:07 25 4
gpt4 key购买 nike

我正在使用新的 MSBuild 内联任务来利用 Microsoft.Web.Publishing.Tasks.dll 程序集中的 TransformXml(XDT 转换)。

这是我的任务(截图)的样子:

<Task>
<Reference Include="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Reference Include="System.Xml" />
<Using Namespace="System"/>
<Using Namespace="System.Linq"/>
<Using Namespace="System.IO" />
<Using Namespace="System.Xml"/>
<Using Namespace="Microsoft.Web.Publishing.Tasks"/>
<Code Type="Fragment" Language="cs">...</Code>
</Task>

这可以很好地编译并加载 DLL,但是,当它执行时失败,因为它试图在 appbase 路径中找到程序集,该路径是:C:\Windows\Microsoft.NET\Framework\v4.0.30319 。我本以为它会看我给它的路径。

Fusion 日志显示:

=== Pre-bind state information ===\r
LOG: User = xxx\Kamran\r
LOG: DisplayName = Microsoft.Web.Publishing.Tasks, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)\r
LOG: Appbase = file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/\r
LOG: Initial PrivatePath = NULL\r
Calling assembly : (Unknown).\r
===\r
LOG: This bind starts in default load context.\r
LOG: Using application configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe.Config\r
error MSB4018: LOG: Using host configuration file: \r
error MSB4018: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.\r
error MSB4018: LOG: Post-policy reference: Microsoft.Web.Publishing.Tasks, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\r
error MSB4018: LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Web.Publishing.Tasks.DLL.\r
error MSB4018: LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Web.Publishing.Tasks/Microsoft.Web.Publishing.Tasks.DLL.\r
error MSB4018: LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Web.Publishing.Tasks.EXE.\r
error MSB4018: LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Web.Publishing.Tasks/Microsoft.Web.Publishing.Tasks.EXE.\r

有什么方法可以解决这个问题,还是我会被迫创建一个任务程序集?

最佳答案

我仍然想要一个真正的答案,但我能够使用反射和加载程序集来解决这个问题。

你可以看到完整的来源in my gist .

关于c# - MSBuild 内联任务 - 引用非标准 Microsoft 程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9455354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com