I want to create a post build script that copies the generated pdb into the gac folder, like this: copy $(TargetDir)$(TargetName).pdb C:\Windows\assembly\GAC_MSIL\$(TargetName)\?Public Token? but i need the public token of the currently build project, is there a way to get this?
A:
From your question, I think you're looking for something you can quickly add to your post-build event from Visual Studio. If you use XCOPY
, you can specify a wildcard in the destination path. That might be sufficient for you:
XCOPY "$(TargetDir)$(TargetName).pdb" "%WINDIR%\Assembly\GAC_MSIL\$(TargetName)\*\"
Another option is to try to extract the public key token using the SN.exe
provided with the framework. This might look something like:
FOR /F "usebackq tokens=5" %%T in (`sn.exe -q -T "$(TargetDir)$(TargetName).dll"`) DO COPY ""$(TargetDir)$(TargetName).pdb" "%WINDIR%\Assembly\GAC_MSIL\$(TargetName)\%%T\"
In reality, though, doesn't the target directory include the assembly version as well as the public key token?
Finally, you can always download the MSBuildExtensions library, which includes an Assembly
task (or implement a custom task yourself). In this case, though, you'll need to edit your proj file manually.
Also, check out the this blog entry - it may be of interest to you.
Dave Cluderay
2009-05-18 23:56:13