Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# project (.CSProj), linking to files with flat directory structure

Tags:

c#

msbuild

csproj

I have a C# class library project, which includes several external files as "links".

In the project file, this comes out as:

<None include="MyFile.txt">
    <link>MyFile.txt</link>
    <CopyToOutputDirectory>CopyIfNewer</CopyToOutputDirectory>
</None>

That works perfectly fine:

  • I see the files in Visual Studio.
  • They are linked prperly, and not copied into my project.
  • The files are copied to the output directory.

But now I want to rearrange my project into directories. In the above, I replaced Myfile.txt with MyDir\MyFile.txt in the link tag.

Now, I end up with a directory called MyDir in the output directory - which I don't want. I would like to have the file in the directory in Solution Explorer, but not in the output folder.

I can't find any way to do this - is it possible?

like image 441
Saqib Avatar asked Nov 04 '22 08:11

Saqib


2 Answers

Solution folders are what you want, I think.

like image 80
Chris Trombley Avatar answered Nov 09 '22 05:11

Chris Trombley


this behavior is by design for avoiding duplicate file conflict and other similar problems.

You should arrange your project files with visual studio Solution folder instead of directories

http://msdn.microsoft.com/en-us/library/sx2027y2.aspx

like image 20
giammin Avatar answered Nov 09 '22 05:11

giammin