Certain user specific configurations are stored in .csproj.user. How do I tell MS Visual Studio to store this information in the .csproj every time?
I had the same problem and the only solution I could come up with was to manually edit the .csproj.user file, cut the configuration I wanted and paste in the .csproj file. It worked fine, despite being a somewhat user-hostile solution.
You can't. Visual Studio stores the user-specific settings in the .csproj.user file, and the build settings in the .csproj file. This is to allow multiple users to work on a project, which is critical when working in a team with source control.
That being said, you can always delete the .user file, and it will be recreated, at any point in time.
Related
I checked the solution file and the project file, and can not find anything related to this setting. When people get latest version from TFS source control, they always see the 'loaded' status, which is not really what I want.
This information is stored in the solution user options file (.suo) which you can find in the same directory as the solution file. As the name implies this is user specific information which means sharing this across the team will be difficult because then everyone will need to live with the same options and store files in the exact location because the .suo file contains full paths.
For anyone else coming here with Visual Studio 2019, the unloading of projects is no longer saved in the SUO (at least in my experience). To save your unloaded project settings, you want to create a solution filter file (.slnf) which is the same as your solution file (.sln) except that it stores which projects you want loaded or not when opening the solution. Once created, you will double-click the .snlf file instead of the .sln file in order to load your filtered projects.
To create the solution filter file you can follow the instructions at this link or follow the summary below:
Open your solution (.sln)
Unload the projects that you want filtered out
Right-click on the solution from within the Solution Explorer
Choose Save As Solution Filter
Choose a location to save the file (I saved it right next my .sln file)
This will add the .slnf to your recently opened solutions list so you can either open from there going forward or navigate to the .slnf file and double-click it.
If you still want to see your unloaded projects after opening the .slnf, highlight the solution from within the Solution Explorer and click the Show All Files icon.
Base on this if you want to share your load/unload setting via source control you can use solution filter file which is .slnf extension.
So when you open the .slnf file instead of .sln file you will see the filtered project are loaded.
On MacOS with Visual Studio 2022 for Mac (i.e. v17.0 Preview, "Visual Studio Community 2022 for Mac Preview") I do not see either .sln nor .slnf files.
I observe that unloaded projects are saved in folder /.vs/[SolutionName]/xs/UserPrefs.xml. And when I close Visual Studio 2022 for Mac, I see that UserPrefs.xml is saved.
UserPrefs.xml Snippet:
<DisabledProjects>
<String>...</String>
</DisabledProjects>
In Visual Studio, if I try to copy a file from one project to another (by using Copy and Paste or by dragging the file to the new project while holding the Ctrl key) it creates a reference to the source file in the original location. Is there a way to create a physical copy of the source file and place that in the target project source direction without having to resort to using Windows Explorer to copy the file manually?
It's not pretty, but when I want to do what you're suggesting, I double-click on the file in Visual Studio, which opens it. Then I do a File->Save As, choose the right directory and save it. All from within Visual Studio. This is usually followed by adding the new file to the other project.
Was just doing this and realized I should mention a side-effect. Depending on your source control (in my case, TFS 2010), doing this from within Visual Studio may modify the location of the file in the project. For me, this means making sure that neither the file nor its project have any pending changes, doing the save as, then doing an undo of the change this causes in TFS 2010 (project change, file add and delete).
From http://msdn.microsoft.com/en-us/library/0fb6xxhb.aspx:
If you are working with solution items, Visual C++ projects, or other similar projects, you are always working with links in Solution Explorer. If you are working with Visual Basic projects, Visual C# projects, and other projects, you might be working with links or files.
Essentially, the answer to my question is 'No'. In most cases, I must use Windows Explorer.
I can open my project by double clicking on the .csproj file. It opens fine and it doesn’t generate a .sln. If I copy the same project to a virtual machine and do the same it opens but creates a .sln file.
I really don’t need a solution I would prefer to only work on a single project.
Am I missing something here?
Visual Studio always creates a solution. If it cannot find one in the same folder as the .csproj file then it will create one itself, based on what it can reverse-engineer from the project file content.
The solution is hidden by default if the solution only contains one project. Fixing this is recommended: Tools + Options, Projects and Solutions, General, "Always show solution" checkbox.
There is always a solution, even if you don't see it. There's a setting that determines whether the solution is visible when there is only one project.
Got a bit of a weird problem. I'm checking a solution out of TFS source control, and not making any changes to it; just opening it using the SLN file. If I then close Visual Studio (or do a Save All), Visual Studio prompts me to save the SLN file. Even if I do (by overwriting it, it's a read-only file), it continues to do this every time I open and close the solution, as if I'd added a project or something. Why would Visual Studio do this? What's causing it to think the solution has changed and needs saving?
OK, problem solved. As we're using TFS for source control, you're meant to check in the SLN file's corresponding .vssscc file. As we'd checked in the .vspscc for the various projects the SLN file pointed to but not the SLN's .vssscc file, Visual studio didn't consider the solution to be bound. :-)
Fixed it by going to File | Source Control | Change Source Control, then binding the SLN file to the solution's root dir on the TFS server. This created the solution's .vssscc file, which we've checked into source control. Subsequent checkouts now don't cause the problem.
I would start by letting it save the solution and then doing a visual diff of the version that it saved vs the one held in source control to see what the problem is. It could just be white space formatting. Also, are you the only person suffering this (if others are using the same solution?)
When I try to open my .sln file, Visual Studio quits on me. I can open it by opening up TFS, getting a specific version, choosing the latest version, forcing an overrwrite, opening up the .sln file, and then ignoring an 'incompatible doc message".
However, I would like to know what's wrong and how it can be fixed, in case some day I can't do this.
How can this be fixed?
I would think this is more likely to be the .suo (which is a hidden file). These are know to corrupt (and this has been true since at least VC++ V6). Deleting it will clear all sorts of odd/erroneous behaviour in VS.
(The .suo holds local settings: which files are open and layout, breakpoints, bookmarks, ... only: nothing that really matters to the solution or projects.)
For Visual Studio 2015 and 2017: rather than being in the same location as the solution (.sln) file, it is now held in a, hidden, folder called .vs in the folder containing the solution file.
In Visual Studio 2022, the .suo is in \.vs\MySolution\v17\
Have you tried creating a new sln and importing all the projs? if it doesn't solve the corruption, it may point to a project with a problem.
Get copies of both versions of the file and use your favorite dif tool to see what's changed. sln files are xml (i.e. human readable), so it isn't too hard to figure out what happened.
Difficult to tell. A sln file is quite simple structured, if you open it with a text editor,
check is everything looks all right to you.
Seems to me that the sln file could be in a conflicted state.