MSBuild GacUtil Community Task Silently Fails For Me

I have a .NET open source project whose main artifact is a DLL that needs to be installed in the GAC for basic use. Therefore, I want to install it during the AfterBuild task. I am using the gbuUtil msbuild task from the MSBuild Community Extensions . He does not work.

My MSBuild code I got from here :

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

The msbuild /t:AfterBuild /verbosity:diagnostic . The error I am getting is:

 Done building target "_CheckForInvalidConfigurationAndPlatform" 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 execute this command from a copy of cmd.exe running as an administrator with gacutil.exe in its path. I used the same command line to successfully install and remove this assembly from the GAC, and double-checked that the assembly was not in the c: \ windows \ assembly folder.

How do I understand why GacUtil is not working?

+4
source share
2 answers

It seems that the path he is trying to use to get the tool is wrong (or at least that was in my case). Set the "ToolPath" property in the "GacUtil" task to "$ (FrameworkSDKDir) bin" like this:

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

Have you checked the value of $ (TargetName) with the Message task?

You may need 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 from the post-build event of Visual Studio:

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

All Articles