ekolis
ekolis

Reputation: 6776

I have a C# solution where the same file belongs to multiple projects. How?

There is a file C:\Users\Me\source\repos\MyProject\VersionInfo.cs that is somehow contained within all but one projects in the MyProject solution; editing one copy of it simultaneously edits all of them, but it only shows up once in source control, at the solution level. How is this possible? How can I add it to the last project? I tried "add existing file" but that just copied it into that folder... if it helps any there is a little blue "arrow in a box" icon on it...

enter image description here

Upvotes: 5

Views: 1482

Answers (1)

Guru Stron
Guru Stron

Reputation: 141730

You have a file which was added as a link. You can read about it for example here or here. You can achieve this via Add -> Existing Item dialog but instead of clicking "Add" click on the dropdown arrow to the right and select "Add As Link":

enter image description here

Or by manually editing .csproj:

<ItemGroup>
  <Compile Include="..\OtherFolder\VersionInfo.cs" Link="VersionInfo.cs" />
</ItemGroup>

Upvotes: 9

Related Questions