How to get public token in post post macros
I want to create a post assembly script that copies the generated pdb to the gac folder, for example: copy $ (TargetDir) $ (TargetName) .pdb C: \ Windows \ assembly \ GAC_MSIL \ $ (TargetName) \ "Public token? But I need the project's public token is currently, is there a way to get this?
a source to share
From your question, I think you are looking for something that you can quickly add to the post-build event from Visual Studio. If you are using XCOPY
, you can specify the template in the destination path. This might be enough 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
one provided with the framework. It might look something like this:
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 fact, doesn't the target directory specify the build version as well as the public key token?
Finally, you can always download the MSBuildExtensions library , which includes the task Assembly
(or you can do your own task yourself). In this case, you will need to manually edit the proj file.
Also, check out this blog post - it might interest you.
a source to share