views:

540

answers:

5

I'm trying to come up with a setup where I can generate a visual studio solution + projectfile, that references files and folders "outside" of the folder where the .sln and .csproj's are stored.

and (the catch :) ), I need new files that get created with you rightclick a folder and say "new code file" to be generated in the folder that was rightclicked, which lives outside of the .sln folder.

Can it really not be done?

PS Sidenote: the reason for wanting to do this is that the .cs files are actually used by a different program, together with a lot of other files, and I don't want the .sln, .csproj, .ReSharper, .suo etc files to clutter my directory.

+3  A: 

Add As Link

http://msdn.microsoft.com/en-us/library/9f4t9t92(VS.80).aspx

Greg Dean
Unfortunattely, that would require the user to first make the file outside of visual studio, and then AddAsLink it. I'm hoping there is a way to wrangle things so that the user can just do Add->NewItem
Lucas
this will require a VS plugin (which are fairly ugly imo)
Greg Dean
A: 

Maybe fsutil hardlink create ?

It wouldn't be hard to have a powershell script that slurps through your VS project directory, and creates hardlinks for each of the .cs files found, in your "other" directory. you could have it set to run every hour, every night, on-demand, whataver.

Cheeso
Right. unfortunately that doesn't solve the problem of not being able to do "Add new item" from visual studio.
Lucas
A: 

Thanks to everybody for their input. It looks like what I want exactly is not possible at this point in time. Bummer.

Lucas
A: 

fsutil hardlink create == http://dotnet-snippets.de/dns/hardlink-erstellen-SID355.aspx

[DllImport("kernel32.dll", EntryPoint="CreateHardLinkA", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true)]
private static extern long CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes);

public void CreateHardLink(String sourcePath, string destPath) {
    CreateHardLink(destPath, sourcePath, IntPtr.Zero);
}
A: 

Hi there, you can read my post that may help: http://ko-sw.blogspot.com/2009/06/reusing-source-files-in-multiple-visual.html