There is a project with a dll, which, after the build, I constantly manually copy into the correct folder. For automation, I tried to specify the Post-build event. Just dll copy is easy:

copy $(TargetPath) $(SolutionDir)..\..\lib\ 

And how can I get a xml description for it? Not strong in bat'anik, is it necessary to cut off the ".dll" extension from $(TargetPath) or are there other ways?

    2 answers 2

    • Visual Studio itself copies all the assemblies ( dll'ки ) and the corresponding xml files into the output folder, if your project on .NET has links to them ( References ), and complex dependency graphs are automatically resolved. Taking into account that you are talking about copying xml files, presumably with the documentation for the assembly, we are talking about some managed assembly.

    Thus, it can be assumed that you simply incorrectly set the References settings in your project, since the dll'ок copying necessary for launching the project should be copied automatically. Files with assembly xml documentation are also copied automatically.


    • If I make a mistake in my assumptions, I can offer you a more general solution. Instead of somehow cutting off extensions from file names and implementing some complex logic in Post-Build Events , do something like the following:

    • Define a lot of files that you always need to copy to the folder with the collected application (in your case there will be an additional dll'ка and the corresponding xml file).

    • Take a special folder for these files in your project. I use folders with data and static_data names in my projects.

    The semantics of these names is as follows - data stores files without which the launch of an application or tests is impossible. It may be some input data, files for test cases, some unmanaged dll'ки , etc. The static_data contains auxiliary data that is simply used in the project - for example, graphical assets , UI sketches, important information in pdf'ках .

    • Next in Post-Build Events add the following command:

    xcopy "$(SolutionDir)data\*.*" "$(TargetDir)" /S /E /Y

    • With this you guarantee that if the project is successfully built, all the files from data will be copied into the Output folder with the assembled application.

    There is one more important point to which you should pay attention - if the files in the data folder are updated, they, naturally, will not be copied into Output before rebuilding the project, which means that at some point in time, despite the fact that you have already updated the files , the assembled application will work with the old set of files. This is quite critical for tests.

    • Not exactly what you need =) I have a spherical project (s) in a vacuum, the output of which (dll and xml) I copy to a specific folder (lib). Different solutions refer to this folder (to dlls in it). This is the process of deployment (if you can call it that) I would like to write in post build. - IronVbif

    Just some other commands in the macro are needed. Here is an example from our project:
    copy / Y "$ (TargetDir) $ (TargetName) .dll" "$ (SolutionDir) .... \ Export \ $ (TargetName) .dll"
    copy / Y "$ (TargetDir) $ (TargetName) .dll" "$ (SolutionDir) .... \ Export \ $ (TargetName) .xml"

    pdb can also be added in the same way