visual-studiocsprojsolution-explorervisual-studio-project

How do I remove files added as link from my project on Visual Studio?


Inside a solution I'm building with Visual Studio 2019, I have a project for a console application. Inside of this project there are references to other files in different solutions, added with the:

Right click on the project → AddReferenceExisting itemsAdd as link

option. I'm afraid that using the Remove option (right click on the files) will also delete the original files since I know that adding a file as link will make it as if the two files were literally the same file. How can I remove these references from the project without deleting the original files from the other solutions?


Solution

  • First of all, you could just delete a link with delete, if it's a link it won't delete the original file. (right click, or press delete on the selected file in the solution explorer)

    You could see if it's linked by it's icon:

    enter image description here

    If you really like to do it manually, then you could edit the csproj file and remove the file with the Link attribute, e.g. remove this line:

    <Compile Include="somewhere\MyClass.cs" Link="MyClass.cs" />
    

    I'm afraid that using the Remove option (right click on the files) will also delete the original files

    Sounds you need a version control system ;)