views:

3379

answers:

4

I would like to implement a post build event that performs the following actions

  1. A relative path copy of the DLL output (1 file, not all the debug jazz)
  2. A register the output DLL to GAC

How is this done?

+3  A: 

Does that do you want?

copy $(TargetPath) $(TargetDir)..\..\someFolder\myoutput.dll
regasm $(TargetPath)

(Entered into the field for post-build step under project properties)

0xA3
On Microsoft Visual Studio 2010, this will fail with a 9009 error: you need to use the full path to regasm, as follows: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe $(TargetPath)
Gravitas
A: 

you may want to look at MS Build. Its what we use here at work.

CodeProject Link & MSDN Ref

Yes, MSBuild is excellent for that. If you want to stay inside Visual Studio you could also enter post-build commands under project properties.
0xA3
+1  A: 

Enter following into "Project properties->Build events->Post build events command line:"

xcopy "$(TargetPath)" "target path" /Y && regasm "$(TargetPath)"

or add following snippet to project (e.g. csproj) file

<PropertyGroup>
    <PostBuildEvent>xcopy "$(TargetPath)" "target path" /Y && regasm "$(TargetPath)"</PostBuildEvent>
</PropertyGroup>

Note that it is recommended to add "" around copy command arguments to avoid problems with paths containing whitespaces. Also note that multiple commands can be combined using &&

aku
A: 

Are you sure you want to do this as part of a compile? I would recommend using project references in solutions rather than the GAC if you can avoid it. Copying files is one thing, but registering in the GAC is fairly intrusive and you may want to consider the other environments your code is compiled in. Things like other developers' machines, and test environments/build servers etc. If you have a build server really you should be using something like NAnt with some sort of continuous integration server.

Neil Barnwell