Copy to Output Directory copies folder structure b

2020-01-24 11:15发布

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条回答
Emotional °昔
2楼-- · 2020-01-24 11:50

Since I cannot comment on previous answers, I will put the solution here:

Adding to what @PaulAlexander provided, add the following to your .csproj/.vbproj file:

<ItemGroup>
    <AvailableItemName Include="RootContent">
      <Visible>false</Visible>
    </AvailableItemName>  
</ItemGroup>
<Target Name="AfterBuild">
    <Copy
        DestinationFolder="$(OutputPath)"
        SourceFiles="@(RootContent)"
        SkipUnchangedFiles="true"
        />  
</Target>

This allows you to select "RootContent" as the Build Action in the Properties window, and all can be accessed via the GUI. A more complete explanation: the "AvailableItemName" option basically creates a new named-list that you can assign items in the project to under the "Build Action" property in the Properties window. You can then use this newly created list in any Target you like (eg via "@(RootContent)").

查看更多
等我变得足够好
3楼-- · 2020-01-24 11:58

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>
查看更多
登录 后发表回答