Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
240 views
in Technique[技术] by (71.8m points)

c# - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)_libfile.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...