Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Visual Studio

Visual Studio: Fix a Startup Project Setting That Keeps Reverting on Its Own

- 27.09.26 - ErcanOPAK

🛠️ The Startup Project That Wouldn’t Stay Set

Setting a specific project as the startup project in a multi-project solution (right-click > Set as Startup Project) feels like a permanent, solution-level choice – but in solutions using newer, SDK-style project formats, that setting is stored in the .sln file itself, and certain workflows (switching git branches to one with a different .sln, or a solution filter file being used instead of the main solution) can silently revert it back to whatever’s written in whichever solution file actually gets loaded, with no obvious indication of why the ‘wrong’ project suddenly starts running again.

🔎 The Problem

Solution: MyApp.sln, containing MyApp.Api, MyApp.Worker, and
MyApp.Tests projects.

Developer sets MyApp.Api as the startup project explicitly through
Visual Studio'"'"'s UI - this writes the choice into MyApp.sln itself.

Later, git checkout switches to a different branch where MyApp.sln
was regenerated by a scaffolding tool, or a .slnf (solution filter)
file is opened instead of the full .sln for a faster, filtered view of
only some projects - either way, a DIFFERENT startup project setting
(whatever that specific file happens to specify, often just the first
project alphabetically) is what actually loads, silently overriding the
explicit choice made moments earlier in the original .sln.

✅ Fix: Know Which Solution File Actually Owns the Setting Being Used

  • Checking whether a .slnf (solution filter) file is what’s actually open, rather than the main .sln, is the first thing worth confirming – a solution filter has its own independent startup project setting, and changing it in the UI while the filter is open updates the filter’s own file, not the main solution’s.
  • For a startup project choice that genuinely needs to survive branch switches and stay consistent for the whole team, committing the .sln file’s startup-project setting explicitly (rather than leaving it as a personal, undocumented preference each developer sets locally) keeps everyone’s environment consistent without each person needing to reset it individually.
  • Multiple startup projects (Solution Properties > Configuration Properties > Startup Project > Multiple startup projects) is worth considering directly for a solution where more than one project genuinely needs to run together during debugging (an API and a background worker, say) – it sidesteps the single ‘set as startup project’ setting reverting unexpectedly by making the multi-project configuration itself the persisted, deliberate choice.

⚠️ Why This Is Confusing Without Realizing Which File Is in Play

  • Visual Studio’s UI for setting the startup project looks and behaves identically regardless of whether a .sln or a .slnf is currently open – there’s no obvious visual cue in the moment that the change being made is going into a different file than expected, which is exactly why the setting can seem to ‘randomly’ revert on a later reopen.
  • This is particularly common on teams that use solution filters specifically to speed up loading a large solution by excluding unrelated projects – exactly the workflow most likely to have a developer regularly switching between the full .sln and one or more .slnf files without necessarily tracking which one is currently open at any given moment.

The startup project setting isn’t reverting on its own – it’s being read from whichever solution file happens to be open, and a .sln and a .slnf are perfectly happy to disagree about it forever.

— Developer Tip

Related posts:

Visual Studio: Use Code Snippets for Faster Coding

Visual Studio: Use Code Snippets for Faster Coding

Visual Studio: Use Live Share for Real-Time Collaboration

Visual Studio: Use Live Share for Real-Time Collaboration

Visual Studio: Use Code Cleanup for Consistent Formatting

Visual Studio: Use Code Cleanup for Consistent Formatting

Views: 26

Post navigation

HTML5: Fix a Progress Element That Renders but Never Visually Updates
Photoshop: Fix a Smart Filter That Reapplies With the Wrong Settings After Reopening a File

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (981)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (653)
  • Add Constraint to SQL Table to ensure email contains @ (609)
  • Average of all values in a column that are not zero in SQL (570)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (547)
  • Find numbers with more than two decimal places in SQL (475)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit
  • SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs
  • C#: Fix an Enum HasFlag Returning True for the Zero Value
  • WordPress: Fix Featured Images Vanishing After a CDN Migration
  • Photoshop: Fix Content-Aware Fill Smearing a Repeating Pattern
  • Asp.Net Core: Fix Antiforgery Tokens Rejected Behind a Reverse Proxy

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (981)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (858)
  • How to select distinct rows in a datatable in C# (854)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com