开发者

MSBuild community task GacUtil silently failing for me

I have an open source .NET project whose main artefact is a DLL that needs to be installed to the GAC for its primary use case. Therefore I want to install it during the AfterBuild task. I am using the GacUtil msbuild task from the MSBuild Community Extensions. It is not working.

My MSBuild code, which I got from here is:

<Target Name="AfterBuild">
  <GacUtil Assemblies="$(TargetName)" />
</Target>

The command I am using is msbuild /t:AfterBuild /verbosity:diagnostic. The error I get is:

Done building target "_Che开发者_运维知识库ckForInvalidConfigurationAndPlatform" in project "JustAProgrammer.ADPR.csproj".
Target "AfterBuild" in project "e:\src\JustAProgrammer.ADPR\JustAProgrammer.ADPR\JustAProgrammer.ADPR.csproj" (entry point):
Using "GacUtil" task from assembly "C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.dll".
Task "GacUtil"
Done executing task "GacUtil" -- FAILED.
Done building target "AfterBuild" in project "JustAProgrammer.ADPR.csproj" -- FAILED.
Done Building Project "e:\src\JustAProgrammer.ADPR\JustAProgrammer.ADPR\JustAProgrammer.ADPR.csproj" (AfterBuild target(s)) -- FAILED.

I am executing this command from a copy of cmd.exe running as administrator with gacutil.exe in its path. I used this very same command prompt to successfully install and uninstall this assembly from the GAC, and double checked that the assembly is not in the c:\windows\assembly folder.

How do I figure out why GacUtil is failing?


It looks like the path it's trying to use to get to the tool is wrong (or at least it was in my case). Set the "ToolPath" property on the "GacUtil" task to "$(FrameworkSDKDir)bin" like so:

<Target Name="BeforeBuild">
    <GacUtil Command="Uninstall" ToolPath="$(FrameworkSDKDir)bin" Assemblies="$(TargetName)" ContinueOnError="true"/>
</Target>
<Target Name="AfterBuild">
  <GacUtil ToolPath="$(FrameworkSDKDir)bin" Assemblies="$(TargetPath)"/>
</Target>


Have you verified the value of $(TargetName) using the Message task?

You may have to specify a property in the build.proj file:

  <PropertyGroup>
    <AssemblyPath></AssemblyPath>
  </PropertyGroup>

  <Target Name="AfterBuild">
    <GacUtil Assemblies="$(AssemblyPath)" />
  </Target>

Then pass the property value in from the Visual Studio post-build event:

msbuild /t:AfterBuild /verbosity:diagnostic /p:AssemblyPath="$(TargetPath)"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜