Copy to Output Directory copies folder structure but only want to copy files

Viewed 59873

I have a VS2008 I want to copy certain files from a directory into my /bin/ folder. I have set the files (located in /common/browserhawk/) to "Copy to Output Directory". However, it copies the folder structure as well: the files are copied to /bin/common/browserhawk/

How do I get these files to copy to just /bin/? I do not want to store these in the root of the website to get them to copy correctly.

Related Question: Visual Studio adds .dll and .pdb to project after compiling

8 Answers

Add the following to your .csproj/.vbproj file

<Target Name="AfterBuild">
    <Copy
        DestinationFolder="$(OutputPath)"
        SourceFiles="@(RootContent)"
        SkipUnchangedFiles="true"
        />  
</Target>

Then change the Build Action of any files you want in the root folder to RootContent.

I ended up adding a step to the nant build file to copy after successful compliation

<target name="action.copy.browserhawk.config" depends="compile.source">
    <copy todir="${App.Web.dir}/bin/" includeemptydirs="false">
        <fileset basedir="${browserhawk.config.dir}">
            <include name="bhawk_bb.dat" />
            <include name="bhawk_sp.dat" />
            <include name="browserhawk.properties" />
            <include name="maindefs.bdd" />
            <include name="maindefs.bdf" />
            <include name="BH_PRO.lic" />
        </fileset>
    </copy>
    <echo message="COPY BROWSERHAWK CONFIG: SUCCESS   ${datetime::now()}" />
</target>

You could build a batch file to copy the files and execute it as a post-build event.

Related