Reputation: 15934
I want to be able to drag .cs files into my project on a per account basis. So I have
<Compile Include="Controls\MyControl.ascx.cs">
then for accounts 001
or 002
I would add an extra line
<Compile Include="Accounts\001\Controls\MyControl.ascx.cs">
OR
<Compile Include="Accounts\002\Controls\MyControl.ascx.cs">
This will allow me to override classes based on the account I am running the project for.
Is it safe to modify the CSPROJ
file in this way or will visual studio overwrite my changes when I add a new file or dependency?
Also, is my approach to the problem reasonable?
Upvotes: 0
Views: 747
Reputation: 239814
If it wasn't safe to manually edit them, I seriously doubt that the option to Edit your project (which opens it as XML) would exist as an option in the context menu of Solution Explorer. (You have to Close the project first to see this option)
Upvotes: 0
Reputation: 31620
A csproj file is basically just an MSBuild script. It is OK to modify it. In your case you would typically use a variable so that you have just one csproj file i.e.:
<Compile Include="Accounts\$(Account)\Controls\MyControl.ascx.cs">
Then the account would be defined as an environment variable or somewhere in your .settings/.targets file depending on where you take it from.
Upvotes: 3
Reputation: 8815
Visual Studio project files are XML files used by the MSBuild script. The editor keeps them updated for you while your working on your project. If you make changes to them while VS is closed, it will load those changes next time you open your project.
Upvotes: 0