Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MSBuild discovery for future scenarios #1328

Merged

Conversation

DustinCampbell
Copy link
Contributor

@DustinCampbell DustinCampbell commented Nov 8, 2018

This change fixes MSBuild discovery to handle scenarios where the MSBuild tools path is not included in a "15.0" folder. In future releases of Visual Studio, MSBuild will move to a folder named "Current" and OmniSharp should support that. In addition, I've added some extra logging during discovery to help indicate why a particular MSBuild instance isn't chosen. Finally, this change introduces a new option that causes OmniSharp to produce MSBuild binary logs when loading projects. This should be a big help for MSBuild debugging. It can be enabled in an omnisharp.json file like so:

{
    "MSBuild": {
        "GenerateBinaryLogs": true
    }
}

This change adds a method for location an MSBuild tools path and shares it among the various
MSBuild discovery providers.
This adds a new OmniSharp option to produce MSBuild binary logs when loading projects
for debugging purposes. The option can be set at the command line or via an omnisharp.json
file:

```JSON
{
    "MSBuild": {
        "GenerateBinaryLogs": true
    }
}
```
@DustinCampbell
Copy link
Contributor Author

Linux is failing because Directory.Exists appears to be case-insensitive. Looking for a good solution...

@filipw
Copy link
Member

filipw commented Nov 8, 2018

In future releases of Visual Studio, MSBuild will move to a folder named "Current" and OmniSharp should support that.

oh wow, thanks for staying on top of that

var binlogPath = Path.ChangeExtension(projectInstance.FullPath, ".binlog");
var binaryLogger = new MSB.Logging.BinaryLogger()
{
CollectProjectImports = MSB.Logging.BinaryLogger.ProjectImportsCollectionMode.Embed,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually the default behaviour so maybe we can skip explicitly specifying it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I guess it is the default: https://github.com/Microsoft/msbuild/blob/master/src/Build/Logging/BinaryLogger/BinaryLogger.cs#L68

That's OK, let's keep the code specific so there's no question. I think our use case is definitely to Embed.

if (_options.GenerateBinaryLogs)
{
var binlogPath = Path.ChangeExtension(projectInstance.FullPath, ".binlog");
var binaryLogger = new MSB.Logging.BinaryLogger()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a great addition, will definitely be useful in troubleshooting

@DustinCampbell DustinCampbell merged commit b442e6b into OmniSharp:master Nov 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants