Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2008 - Moving files at build to bin/

EDIT: This is a VS2008 app written in C#.

So I have a folder in my solution called

_lib/ 

It's where I keep my DLLs so that when I reference them, they get built into the bin/ folder.

Now I have a new item in my solution. It's a DLL but shouldn't be reference (it's required for a 3rd party app). So on build I want this to be copied from _lib/ to bin/ but NOT referenced in the project.

I've included the _lib/ folder in my app, and for the properties of that DLL I selected always copy. This ALMOST worked, it copies the file with the folder, so my structure looks like:

/bin/_lib/thedll.dll

Instead of

/bin/thedll.dll

Any ideas?

like image 606
Ev. Avatar asked Feb 15 '11 00:02

Ev.


People also ask

How do I change the build output directory in Visual Studio?

To place all solution outputs in a common directory Click on one project in the solution. On the Project menu, click Properties. In each project, depending on its type, select either Compile or Build, and set the Output path or Base output path to a folder to use for all projects in the solution.

How do I change the location of a file in Visual Studio?

In Visual Studio, click Tools > Options. Expand Projects and Solutions and click Locations. The Projects location field defines the default location for storing new projects. You can change this path if you are using a different working folder.

How do I move files from one project to another in Visual Studio?

This is the "show all files" button. Click that and you'll see all the files in your currently selected project (it is project-specific). Highlight any files that you want to include, right-click, and select "Include in Project."

What is OutDir Visual Studio?

$(OutDir) is a Visual Studio Build Property Macro. You can see the values of macros using the Macros >> button in many Properties dialogs. For instance, in Properties->General->Output Directory, click the dropdown in the value text box, choose Edit..., and in the resulting dialog, click the Macros >> button.


1 Answers

Try following these steps in Visual Studio:

  • Expand the project tree concerned

  • Double click the Properties element

  • In the opened window click the Build Events tab

  • In the Post-build event command line text area place this:

    xcopy "$(ProjectDir)_lib\file.ext" "$(ProjectDir)bin\$(ConfigurationName)"
    
  • Open the expected output folder alongside Visual Studio

  • Hit CTRL+Shift+B to make sure everything is saved and build

  • Feel the sense of achievement well up inside you as your file appears

  • :)

Oh, and you can now set Copy to output directory to Do not copy.

like image 188
Grant Thomas Avatar answered Sep 25 '22 15:09

Grant Thomas