Since VS2017 returned to csproj, I am again able to add files \"as link\"... NOT!
When I link a file I also want it to be copied to the solution folder (not output direc
Ok I pulled it off, but it is not nice.
First of all, lets understand what the problem was. 1. Add CONTENT (js, ts, css, images) files "as link" 2. Files need to be physically there. Why? In a classic web, you need those resources in the output directory, cause they're going to be needed only when running the app. Since mines is a webapi + angular app, I need to actually work a lot with these files and also they have to be available to my IDE physically. First of all, webpack needs to compile them, I have less and sass files that are also compiled. I also do chrome debugging... files need to be there... so you make a msbuild task to move files from their source location to your destination. Files must be copied again (if chenged) from their source. This is a standard practice, not a hack of myself 3. On reload, visual studio sees the links and tryes to (virtually) add them to project structure .Now here's the problem... files are already there, cause you forced them to be there in point 2.
The reason why this works in 2015 is because csproj in 2015 does not inspect the folder structure to list its content. Files should be declarated in csproj in order to be in the project structure. Now 2017 uses a mix of csproj and the old "website" project, which would list the directory contents. Since vs 2017 "sees" the files, then it gets confussed when trying to add them...
So my work around was to change my csproj in this way:
so it looks like this: REMOVE
ADD.
app\core\somefile.ts
COPY ON BUILD
I would also like to mention that I improved it a bit to be recursive so I dont end up with all references in there, so my point 2 actually looks like this:
app\Core\%(RecursiveDir)%(FileName)%(Extension)
After many days of fighting with this I must say I am not 100% happy with the journey of csproj 2015 to xproj 2017 to csproj 2017. I think it was done with a good harth but they screwed a LOT of programmers with the way it was handled. I still love it, but it made me (and many others) suffer a lot and waste many many days in simmilar matters. This issue I faced was just one among many in a sea of documentation that goes obsolete, project name changes, and such.