I have been using this code below to include the files to the project.
var project = new Project(projectFile);
project.AddItem("Compile", fileToAdd);
project.Save();The file already exists in the project directory before the code is ran.
The problem is if the file is already included in the solution, and this is ran again, there will be a duplicate of the same file.
Is there are way to check if the file is already included in the solution?
The code below only checks if the file exists physically in the project folder, but not if it is included in the solution.
System.IO.File.Exists(pathToSourceFile)