Functoids 需要在 GAC 中吗?

Functoids need to be in the GAC?

我希望我在这里忽略了一些东西,但我遇到了一个问题,为此我找不到合适的解决方法。

我将 VSTS 用于我的 CI 解决方案。每次提交时,BizTalk 应用程序都会被提取到专用的构建服务器,进行编译并执行单元测试。

我不希望我的任何 BizTalk 解决方案程序集找到进入生成服务器上的 GAC 的方式,因为 Visual Studio 将使用这些而不是项目引用进行编译。

当构建代理尝试构建包含自定义 functoids 项目的解决方案时出现问题,我收到以下错误:

Functoid not found: guid (1d5de785-c639-4040-9704-c65a11127115) with functoid id (6003). Check if the assembly implementing this functoid is present in D:\Program Files (x86)\Microsoft BizTalk Server 2013 R2\Developer Tools\Mapper Extensions. If the functoid does not expose any inline code, make sure its assembly is made available in the GAC also

那么,functoid 程序集需要在 GAC 中吗?麻烦的是,它引用了一个 common.components 程序集,这意味着它也需要进行 GAC,这让我回到了我不想去的地方!这是一个问题,因为下一次构建代理尝试构建一个引用 common.components 的项目时,它将使用恰好在 GAC 中运行的 "old" 版本,而不是最新的版本刚刚从存储库中提取并与同一解决方案中的依赖项目并存。

如果其他人遇到了同样的问题,我很乐意听取您的意见。

我通常在我的 BizTalk 相关项目中将以下内容作为 post-build 步骤:

call "$(DevEnvDir)..\tools\vsvars32.bat"
gacutil.exe /if "$(TargetPath)"

我相当确定 $(DevEnvDir) 不会在生成服务器上解析。有一些解决方法——您可以确保安装 Windows SDK 并设置正确的注册表项(如此处 Running MSBuild fails to read SDKToolsPath), or you could just otherwise set an environment varaible on the build server that has the path to gacutil, or you could use something like the MSBuild community tasks (https://github.com/loresoft/msbuildtasks),它有一个 GacUtil 任务,甚至可能 运行像这样的 powershell 脚本:

#Note that you should be running PowerShell as an Administrator
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")            
$publish = New-Object System.EnterpriseServices.Internal.Publish            
$publish.GacInstall("C:\Path\To\DLL.dll")

(来自 https://www.andrewcbancroft.com/2015/12/16/using-powershell-to-install-a-dll-into-the-gac/)。

请注意,构建过程需要 运行 具有(本地)管理权限才能成功对库进行 GAC。

编辑:因为我已经 运行 在本地解决了这个问题,所以我使用了它并且它在我测试过的每个环境中都有效(无论安装了哪个 windows SDK 或者是否机器的管理员把它放在 C、D 或其他驱动器上...):

powershell -c "[System.Reflection.Assembly]::Load('System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'); $publish = New-Object System.EnterpriseServices.Internal.Publish; $publish.GacInstall('$(TargetPath)');"

感谢@Johns-305 的回答 - 我想多了!

我将以下内容添加为 Common.Components 项目的 post 构建事件:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe"  /i "$(TargetPath)"