Using GACUTIL in Post-build event in Visual Studio on Windows 10

557 views Asked by At

I have a Visual Studio 2012 project that creates an SSIS custom task. In the Post-build event, I have this:-

cd $(ProjectDir)
@SET TASKDIR="C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Tasks\"
@SET GACUTIL="C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe"
Echo Installing dll in GAC
Echo $(OutDir)
Echo $(TargetFileName)
%GACUTIL% -if "$(OutDir)$(TargetFileName)"
Echo Copying files to Tasks
copy "$(OutDir)$(TargetFileName)" %TASKDIR%

which used to work with Windows 7.

Today, for the first time, I have tried to do this on Windows 10 and I'm getting:-

Failure adding assembly to the cache: Administrator permissions are needed to use the selected options.

If I start a command window as Administrator and use the command:-

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe" -if "C:\Users\Kevin\Documents\Visual Studio 2012\Projects\SSISCompressionTask\SSISCompressionTask\bin\Debug\<Task Name>.dll

it works.

How do I continue to put the assembly in the GAC from the Post-build event in Visual Stusio please?

Thanks

1

There are 1 answers

0
Kevin Balmforth On

I started Visual Studio as an administrator and that now allows me to install the dll in the GAC and to copy the files to the Tasks folder which, I hadn't mentioned, wasn't working either.

If you want to ensure Visual Studio always runs as administrator,

Start Menu -> More -> Open file location

Start Menu -> More -> Open file location

Right click on the file and select properties. In this Shortcut tab, select Advanced...

Click Advanced...

In the Advanced Properties window, check the "Run as administrator" button

Check run as administrator

Ok, Ok and now you've modified the shortcut to always launch Visual Studio as an administrator.