Reputation: 1407
I have a VS2010.NET solution with many projects. One of the projects has a non-source code directory in it. When I build this solution, I need to have that directory copied over to the solution build output directory. What I am trying to do is access the files in that folder at my solution runtime. Since this application will be distributed to multiple computers, I need to also distribute this set of data files.
To review, here's what my (simplified) solution hierarchy looks like
solution
|
+----MainProject
| |
| +----source.cs
|
+----SupportPorject
|
+----source.cs
+----MyFolder
|
+----DataFile1
+----DataFile2
+----DataFile3
When I build the solution, I would like to have the following
solution
|
+----bin
|
+----Debug
| |
| +----Solution.exe
| +----SupportProject.dll
| +----SupportProject.pdb
| +----MyFolder
| |
| +----DataFile1
| +----DataFile2
| +----DataFile3
|
+----Release
|
+----Solution.exe
+----SupportProject.dll
+----MyFolder
|
+----DataFile1
+----DataFile2
+----DataFile3
Upvotes: 2
Views: 1615
Reputation: 1407
After a lot more research, I stumbled on the answer (in part based on this answer to a similar question). The solution involved hand modifying the SupportProject.cproj file with the following
<ItemGroup>
<Content Include="MyFolder\**">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Upvotes: 1
Reputation: 3697
Another solution is edit yours .csproj and search for OutputPath tags. For Debug output, it must look similar to:
<OutputPath>bin\Debug\</OutputPath>
According to your requirements, set it to:
<OutputPath>..\bin\Debug\</OutputPath>
Upvotes: 1
Reputation: 1960
Visual Studio also has an option to copy files to the output directory. Just change your content from "Do Not Copy" to "Copy Always". You can find the setting in file properties.
Upvotes: 0
Reputation: 416
You may want to use Xcopy in your Visual Studio Build Pre/Post events depending on the sequence you need the files in. xcopy SourceFolder $(SolutionDir)YourFolderNameHere*.*" /E /H
As explained in this post over here
Upvotes: 1