PistonDevelopers / VisualRust

Visual Studio extension for Rust
MIT License
701 stars 73 forks source link

Build and project bug fixes possibly related to Visual Studio 2017 compatibility #277

Closed MathiasPius closed 7 years ago

MathiasPius commented 7 years ago

I've fixed a few issues I encountered whilst trying to build and use the latest version of Visual Rust.

1) When trying to build a project generated from the standard Rust Application template, MSBuild would crash, because the json-formatted feedback returned from the cargo build command didn't contain a .message component referenced in the LogRustcMessage function. I've chosen here to just exit the logging function early since there's no real message to log. I'm not sure if the information contained in the parent message object itself is perhaps relevant to the output window still.

2) When you open a file in a project and save it, the MsBuildFileSystemWatcher would produce an error, because Visual Studio 2017* briefly creates a temporary file in the project directory, and in the process of checking its relevance to the project, the MsBuildFileSystemWatcher would attempt to shorten the path of the file after the temporary file was already removed again. This causes the ToShortPath function to throw a Win32Exception that was not handled in the IsFileAllowed function. Since the file no longer exists, the accessibility of the file is a little irrelevant, so I just caught the error so the function returns false.

3) The code for loading a project file from scratch sets up an empty project, and then intends to mark it as dirty before requesting a rebuild of the project tree, but never actually marks it as dirty. This means that loading an existing solution from disk yielded a tree in the Solution Explorer containing only the solution and the project itself, but none of the items contained within. It required you to unload and reload the project through the Solution Explorer to actually see the files and folders that made up the project.

MaulingMonkey commented 7 years ago

Looks like I've accidentally duplicated some (but not all!) of the work here in https://github.com/PistonDevelopers/VisualRust/pull/286 . Was this intentionally closed?

MathiasPius commented 7 years ago

There seemed to be little interest in it, and it looked like there were a lot of other - bigger - efforts to achieve VS2017 compatibility so I figured my small changes would probably be irrelevant at best, or conflicting at worst.

It looks like your PR is one such effort, so if you can get anything useful out of this one, help yourself :)