views:

244

answers:

3

I'm trying to use the post build command line to get my class library in the GAC. It is:

"%programfiles%\Microsoft SDKs\Windows\v6.0A\Bin\x64\gacutil.exe" -if $(TargetPath)

I do not see any errors, but my DLL is not getting into the GAC. However, I can run this from a DOS prompt and it works. Anything special I need to do to make this command work in VS like this?

+1  A: 

Are you running under Vista, Win7 or Win 2008 and UAC is making Visual Studio run in a non-admin context ? And you are launching the command prompt with admin privileges ?

Timores
I am logged in as Administrator, on Windows 2008 R2 Server, so yes, when I open a DOS command window, that is who i am, are you thinking it is not the same when I am running in VS? What is UAC?
bmw0128
UAC is User Access Control, it is a way of reducing your privileges even when you are an admin. If an action requires admin privileges, a pop-up asks you if you're the one who triggered the action; its purpose is to prevent malware from acting on your behalf, without you noticing.If think that on Win2K8 R2, a command prompt is run with UAC turned off so gacutil runs fine. Try right-clicking on your VS shortcut and find 'runs as admin', select it and try again.
Timores
tried and no go, I right clicked and chose "Run as Administrator", I did not do anything with UAC, should I look into that?
bmw0128
No, I think I was wrong. If UAC were on, it should have prompted you if you "want to allow the following program to make changes to this computer" with a title of "User Access Control".Sorry.
Timores
A: 

You might need double quotes around the target: "$(TargetPath)"

Mark Wilkins
that did not do it
bmw0128
If your path had no spaces in it, then I guess it wouldn't make any difference. And come to think of it, if there were spaces I think you would have seen an error in the output.
Mark Wilkins
+1  A: 

The answer is that on a 64 bit system, %programfiles% needs to be replaced with

%ProgramW6432% or %ProgramFiles(x86)%

Thanks for all of the help.

bmw0128
sorry, i did not mention that i am on a 64 bit OS
bmw0128
It's curious that no error occurred. I thought about the 32-bit versus 64-bit issue ... but I was thinking it should have showed some kind of error if it didn't like the binary. Anyway, +1 for following up and reporting the answer.
Mark Wilkins