Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

How to deal with .csproj.user being created/modified by Visual Studio before the project is run?

$
0
0

So, what is the problem?

The problem is that Visual Studio considers .csproj.user a dependency of the project being run.

Let us assume the following:

 - We have a freshly built solution containing a web application project `X` as the Start Up project. 
 - There are Silverlight applications served by the X web application.
 - There is no `X.csproj.user` file initially.

Now consider the following flow of events:

 1. Open the solution in the Visual Studio
 2. Build.
 3. Run.
 4. A dialog is open to ask whether Silverlight debugging is to be enabled. Enable it.
 5. Stop the debugging session.
 6. Run again.
 7. Stop the debugging session.
 8. Run again.

Assuming nothing is built at step 2 (because the solution is totally up to date), will there anything be built at steps 3 and 6?

The answer is affirmative and here is why:

 - The X.csproj.user file is actually created by Visual Studio when the project is requested to run. What happens next is that the X.csproj.user file is considered a dependency of the project X by the Visual Studio. Being created just now the file is newer than the project binaries and so Visual Studio builds the project X. This explains why the project is built at step 3.
 - When we agree to enable Silverlight debugging Visual Studio records this agreement in theX.csproj.user file. So the file is modified again, after the project has started running. Restarting the debugging session is going to build the project X yet again, after allX.csproj.user is again newer than the binaries built a second ago. This explains why the project is built at step 6.

Fortunately, nothing is built at step 8.

Call me petty, but I want to avoid the builds at steps 3 and 6. The problem is that I am not allowed to check in the X.csproj.user file, because that is likely to create a mess with people accidentally checking in their private changes.

On the other hand, I am unable to move its default content (along with the agreement to enable Silverlight debugging) into the project file X.csproj. Well, I can, but it is just being ignored.

So, here is my question - is it possible to separate the content stored in a .csproj.user into two groups:

 - Permanent. These are the things I would love to have in the .csproj file. It will be checked in.
 - Temporary/Private. These are the things private to individual developers. Never checked in.

Visual Studio already allows this separation for certain properties - see the Apply server settings to all users (store in project file) checkbox in the Web properties tab of a Web application project - http://olalalittlen.wordpress.com/2011/07/20/vs-tips-managing-server-settings-in-web-projects-for-multi-developer-scenarios/. However, it is insufficient.

Any other ideas on how to prevent the aforementioned redundant builds are welcome too.


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>