Drag and drop .cs files without using the Add As Link link in Visual Studio

Is there a way to use add-as-link when dragging source files or entire source trees to a C # project?

Dragging and dropping the source tree to the C # project currently causes Visual Studio to copy all the files to the mirror tree below my solution file.

This can be avoided with the option to add a link, as shown in the figure below. However, it becomes tedious for large trees or when some files in a directory are already part of the project.

Screenshot of add-in functionality in Visual Studio http://jaapsuter.com/images/add_cs_file.jpg

I looked through Tools-> Options, searched the Internet and made various combinations of magic keys when dragging and dropping, but to no avail.

I am tempted to write a script that simply drags my .cs files and runs a regex over my .csproj file. I know NAnt, Premake and other solutions, but I would like something easy.

+4
source share
3 answers

What you can also do if you donโ€™t find a solution, binds the directory to your project manually, and let the project automatically find all the .cs files in this directory when it loads.

This is easy to do by modifying the MSBuild file as follows:

<ItemGroup> <Compile Include="SomeDirectory\**\*.cs"/> </ItemGroup> 

It will take all .cs files in SomeDirectory and include them in the project. This is very useful if a lot of files are added to the project. However, this may break on some machines that add useless files. Therefore, I would recommend only an external project that is not edited in your workspace.

+1
source

Despite the fact that this question was answered, I thought I would provide another way, because I found this question, finding out whether it is possible to add related files to Visual Studio using drag and drop, and not cumbersome adding box elements. And although the answer here was not what I was looking for, I found out myself:

Holding CTRL + SHIFT down while dragging, create related files. In addition, holding only CTRL will create copies, but will not delete the original file.

+4
source

Probably not what you are asking for, but as soon as I had two .NET applications that I wanted to share a large number of source files, so I put both Visual Studio solutions in the same directory ! It really works, although I think a lot can be said about this approach ...

Otherwise, the most beautiful way to exchange code is to place the common code in a separate assembly, although this requires quite a lot of additional work if it is not written first.

+1
source

All Articles