Conversation
A new build task project allows us to open the startup file after the build finishes (this proved to be the most reliable way that didn't cause editor instabilities). The behavior can be turned off by setting the MSBuild property `OpenStartupFile` to false. The logic seems convoluted, but it's really the only way. The Roslyn stuff runs out of process from VS and therefore cannot interact with it in any (normal) way. We take inspiration from the xunit.vsix project (see https://github.com/kzu/xunit.vsix/blob/master/src/Xunit.Vsix/RunningObjects.cs) to basically lookup via COM the running DTE for the active window (since you have just changed the startup profile, this will almost surely be the process we're interested in) and just run a DTE `File.Open` command against it. This has the benefit of focusing the tab if it's already opened but not focused, btw. We keep the last opened file in a flag file too, so as not to force open a file that you have explicitly closed after the initial auto-open, to avoid being too annoying. This flag file is *not* added to the FileWrites because we don't want a rebuild to cause files to re-open unnecessarily.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A new build task project allows us to open the startup file
after the build finishes (this proved to be the most reliable
way that didn't cause editor instabilities).
The behavior can be turned off by setting the MSBuild property
OpenStartupFileto false.The logic seems convoluted, but it's really the only way. The
Roslyn stuff runs out of process from VS and therefore cannot
interact with it in any (normal) way. We take inspiration from
the xunit.vsix project (see https://github.com/kzu/xunit.vsix/blob/master/src/Xunit.Vsix/RunningObjects.cs)
to basically lookup via COM the running DTE for the active window
(since you have just changed the startup profile, this will almost
surely be the process we're interested in) and just run a DTE
File.Opencommand against it. This has the benefit of focusingthe tab if it's already opened but not focused, btw.
We keep the last opened file in a flag file too, so as not to
force open a file that you have explicitly closed after the
initial auto-open, to avoid being too annoying.
This flag file is not added to the FileWrites because we don't
want a rebuild to cause files to re-open unnecessarily.