Reputation: 449
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.
Upvotes: 9
Views: 10464
Reputation: 2453
The solution I found was to install the Visual Assist extension, which allows adding a file relative to the directory or your currently open file.
See my previous post for further explanation.
Upvotes: 0
Reputation: 2802
For anybody who is interested, it is possible to have a "linked" folder in the solution explorer instead of just the linked files appearing all on the root of the solution. Include the following in the csproj/vbproj files.
<ItemGroup>
<None Include="..\MyFolder\*.*">
<Link>MyFolder\A\</Link>
</None>
</ItemGroup>
This will include all files from the 'MyFolder' directory one level up from the project. The 'A' can be called anything but must be there in order for the folder to appear in the solution explorer. Unfortunately using this technique you cannot add new files from the IDE as they will be added to a folder of the same name in project directory instead of to the linked directory.
Upvotes: 3
Reputation:
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);
}
Upvotes: 0
Reputation:
you can read my post that may help: http://ko-sw.blogspot.com/2009/06/reusing-source-files-in-multiple-visual.html
Upvotes: 2
Reputation: 449
Thanks to everybody for their input. It looks like what I want exactly is not possible at this point in time. Bummer.
Upvotes: -2
Reputation: 192657
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.
Upvotes: 0
Reputation: 30107
Add As Link
http://msdn.microsoft.com/en-us/library/9f4t9t92(VS.80).aspx
Upvotes: 8