Rust-VisualRust: Visual Studio extension for Rust

Visual Studio extension for Rust

Build status

Screenshot

Currently in development, and not feature complete. Stable versions are available on the Visual Studio extension gallery.

Unstable, but more recent builds are downloadable from AppVeyor (choose "Configuration: Release" and "Artifacts").

Features

  • Project support based on Cargo
  • Syntax highlighting
  • Autocomplete
  • Go to definition
  • Debugging for both MSVC and GNU toolchains
    • Conditional breakpoints
    • Watch window (with the ability to change the runtime state)
    • Immediate window (with the ability to change the runtime state)
    • Set next statement
    • Call stack view and navigation

Contributing

How to contribute?

Issues

Feel free to open issues, post comments about progress, questions, new ideas, brain storming etc. You can remove and edit comments as a way of refining ideas in the issue tracker. This is very helpful because many concerns in this project are very complex. Many issues needs to be broken down into new issues before they can be implemented.

Issues marked Ready represent tasks that have a clear design and deliverables. They are recommended starting points if you don't want to spend time discussing and evaluating implementation.

Issues marked Information require some wider perspective and discussion. They are perfect if you want to have an impact on the project but don't have the time to spend coding.

Code

  1. Fork the main repository
  2. Work on a feature in your own private branch
  3. Once you are finished with you work or want someone to you, open a pull request
  4. Someone will review your code and merge it. Some fixes might be required on your side.

Prerequisites

To build this, you'll need Visual Studio 2015 and matching Visual Studio SDK for the VS plugin, WiX Toolset 3.10 or higher for the setup project and Java RE. NuGet will take care of the rest.

Build configuration

If you plan to hack on Visual Rust you should understand difference between our two build configurations.

  • For the Release configuration the main project is VisualRust.Setup, its output is a .msi file that consists of two parts:

    • MSBuild integration: this lets you build Rust projects (.rsproj) from the command line and Visual Studio.
    • Visual Studio plugin(s): this adds support for Rust projects (.rsproj) inside Visual Studio. Syntax highlighting, project system, item templates. Everything except building.
  • For the Debug build main project is called simply VisualRust and it builds VisualRust.vsix which is a VS plugin in a format that is suitable for local installation and debugging. It doesn't contain MSBuild integration

Consequently, for the debug build you'll want to either install just MSBuild integration from the .msi file or build it yourself (VisualRust.Build) and copy to %ProgramFiles(x86)%\MSBuild\VisualRust.

Also you'll want to modify VisualRust project with location of your Visual Studio installation to launch it automatically when debugging.

Contact

This project is currently maintained by vosen.

Feel free to mail him or ask around in #rust-gamedev on irc.mozilla.org.

License

Same as Rust, dual MIT/ASL2. Any contributions made are under this license.

Comments

  • Git LFS Quota issues
    Git LFS Quota issues

    Jul 29, 2017

    I may have discovered why only master branch release builds were being built: git LFS quotas:

    https://ci.appveyor.com/project/MaulingMonkey/visualrust/build/job/26a7xmxwanmx0snv

    git clone -q --branch=master https://github.com/MaulingMonkey/VisualRust.git C:\projects\visualrust
    Downloading build/7za.exe (1.03 MB)
    Error downloading object: build/7za.exe (ff3706e): Smudge error: Error downloading build/7za.exe (ff3706e94d9b769f78e4271928382426cb034b11c5a0f6a8ffea35726cc03692): batch response: This repository is over its data quota. Purchase more data packs to restore access.
    

    Apparently my fork counts against your quota. Sorry about that. build\ accounts for ~2MB, lib\ accounts for ~100MB in the form of two .7z files, apparently containing mingw installs. As a temporary measure I've disabled appveyor builds from my repository.

    It looks like there may be ways to enable caching:

    http://help.appveyor.com/discussions/problems/6274-git-lfs-and-build-cache

    Some Options

    • ~~Bribe~~ donate to whoever runs PistonDevelopers to get our quota increased
    • Hack up appveyor's build scripts to cache lfs stuff (might not be sufficient)
    • Switch to an external package manager (chocolatey? lpg likes vcpkg?)
    • ~~Just stop using git lfs and put things directly into the repository~~
    • ???

    What it's used for

    MinGW

    • build/7za.exe -- used to unpackage lib/*.7z
    • lib/i686-7.1.0-release-posix-dwarf-rt_v5-rev0.7z 32-bit MinGW
    • lib/x86_64-7.1.0-release-posix-seh-rt_v5-rev0.7z 64-bit MinGW We then repackage gdb and some dependencies from mingw directly into the .vsix as I understand it to enable some built in debugging: https://github.com/PistonDevelopers/VisualRust/blob/master/lib/mingw.msbuild . This could be axed in favor of:
    • Windows Subsystem for Linux (Win 10+)
    • https://chocolatey.org/packages/mingw/ Alternatively, it might be worth seeing if it might be preferable to rely on one of the other existing integrations of gdb into visual studio instead of rolling our own...?

    StrongNamer

    • build/StrongNamer.0.0.5/Mono.Cecil.Mdb.dll
    • build/StrongNamer.0.0.5/Mono.Cecil.Pdb.dll
    • build/StrongNamer.0.0.5/Mono.Cecil.Rocks.dll
    • build/StrongNamer.0.0.5/Mono.Cecil.dll
    • build/StrongNamer.0.0.5/StrongNamer.dll I believe these allow us to use unsigned dependencies from signed assemblies. Might be worth seeing if we can get rid of the dependency by signing more of the projects. There are also nuget packages:
    • https://www.nuget.org/packages/StrongNamer/
    • https://www.nuget.org/packages/StrongNamer.For.MsBuild12/
    hard ready 
    Reply
  • No Rust installation detected. You can download official Rust installer
    No Rust installation detected. You can download official Rust installer

    Aug 22, 2017

    I've installed visual rust 0.1.2, I have rustc.exe and some other files installed here: C:\Users\steve.cargo\bin But when I try to build rust project in msvc 2015 I get this error:

    C:\Program Files (x86)\MSBuild\VisualRust\VisualRust.Rust.targets(53,5): error : No Rust installation detected. You can download official Rust installer from https://www.rust-lang.org/downloads.html

    How is the installation detected? How can I fix this?

    bug 
    Reply
  • Latest build fails to install
    Latest build fails to install

    Oct 13, 2017

    I was looking for the latest version which supports Cargo build. So I downloaded the 154 build (VS2015) But it fails to install with the error:

    The file is not a valid VSIX package

    Visual Studio 2017 (Community) The plugin installs ok. But no Rust project template under "New Project" category

    bug 
    Reply
  • VS now supports the Language Server Protocol
    VS now supports the Language Server Protocol

    Nov 21, 2017

    https://blogs.msdn.microsoft.com/visualstudio/2017/11/21/announcing-language-server-protocol-preview-release/

    discussion 
    Reply
  • visualrust with vs2017 doesn't seem to work
    visualrust with vs2017 doesn't seem to work

    Jun 8, 2018

    I'm using visual studio community 2017 (15.6.3) and I'd like to use Visual Rust with it. I installed the bin\VisualRust.Setup.2017\Release\VisualRust.Setup.2017.exe artifact (dated December 4th, 2017) from https://ci.appveyor.com/project/vosen/visualrust/build/artifacts (I couldn't find any other version for VS2017. It installed just fine with no errors. When I started VS back up, I don't see anything different---no new templates or project types or anything. VS2017 does think it's installed (based on going to tools/extensions), it just doesn't seem to do anything. If I go to add new project or add new file and look/search for rust, nothing.

    However, if I open a .rs file in VS, it does syntax highlight it, but "go to definition" doesn't work, and I can't build.

    Reply
  • is a vs 2017 extension available?
    is a vs 2017 extension available?

    Jan 18, 2019

                                                                                                                                                                                                           
    Reply
  • Add debugging support
    Add debugging support

    Aug 14, 2014

    This is of course predicated on rustc emitting debuginfo (pdb?) that Visual Studio can understand, but there's nothing nicer than Visual Studio's debugger.

    Reply
  • Rust error format updates and IDE support
    Rust error format updates and IDE support

    Aug 8, 2016

    I'm not sure if this will impact you, but I wanted to mention that we're currently talking about updating the Rust error format. For plugins using a regex style parse of the errors, this will likely have some impact.

    If this PR is accepted, it will only initially impact the nightly builds. There are some weeks between the PR going it and a stable release including the new format. We'd like to use that time to make the transition as easy as possible.

    As part of the PR, we're also enabling a supported JSON mode which IDE plugins can optionally use. It has the same information as the error text, but in a more structured way.

    Please feel free to jump in on the PR thread and let us know if this impacts your plugin.

    Reply
  • Json error format
    Json error format

    Aug 27, 2016

                                                                                                                                                                                                           
    Reply
  • [VS 2017; latest build] Installation of extension fails
    [VS 2017; latest build] Installation of extension fails

    May 12, 2017

    Environment:

    Windows 10 Pro N x64 (before Creators update) Version: 1607 OS Build: 14393.1066

    Visual Studio:

    Microsoft Visual Studio Community 2017 
    Version 15.1 (26403.7) Release
    VisualStudio.15.Release/15.1.0+26403.7
    Microsoft .NET Framework
    Version 4.6.01586
    
    Installed Version: Community
    
    Visual Basic 2017   00369-60000-00001-AA658
    Microsoft Visual Basic 2017
    
    Visual C# 2017   00369-60000-00001-AA658
    Microsoft Visual C# 2017
    
    Visual C++ 2017   00369-60000-00001-AA658
    Microsoft Visual C++ 2017
    
    ASP.NET and Web Tools 2017   15.0.30320.0
    ASP.NET and Web Tools 2017
    
    GitHub.VisualStudio   2.2.0.10
    A Visual Studio Extension that brings the GitHub Flow into Visual Studio.
    
    JavaScript Language Service   2.0
    JavaScript Language Service
    
    JetBrains ReSharper Ultimate 2017.1.2    Build 108.0.20170428.75743
    JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2017 JetBrains, Inc.
    
    KofePackagePackage Extension   1.0
    KofePackagePackage Visual Studio Extension Detailed Info
    
    Microsoft MI-Based Debugger   1.0
    Provides support for connecting Visual Studio to MI compatible debuggers
    
    Microsoft Visual Studio VC Package   1.0
    Microsoft Visual Studio VC Package
    
    Visual C++ for Linux Development   1.0.6
    Visual C++ for Linux Development
    
    Visual Studio tools for CMake   1.0
    Visual Studio tools for CMake
    
    Visual Studio Tools for Unity   3.1.0.0
    Visual Studio Tools for Unity
    

    Steps to reproduce

    1. Download build from: https://ci.appveyor.com/project/vosen/visualrust/build/152/artifacts
    2. Perform installation

    Actual result

    The installation fails with The InstalledByMSI element in extension Visual Rust cannot be 'true' when installing an extension through the Extensions and Updates Installer. The element can only be 'true' when an MSI lays down the extension manifest file..

    Related: #271, #275

    Full log

    12.05.2017 19:20:30 - Microsoft VSIX Installer
    12.05.2017 19:20:30 - -------------------------------------------
    12.05.2017 19:20:30 - vsixinstaller.exe version:
    12.05.2017 19:20:30 - 15.0.26209.1 built by: D15REL
    12.05.2017 19:20:30 - -------------------------------------------
    12.05.2017 19:20:30 - Command line parameters:
    12.05.2017 19:20:30 - C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\VSIXInstaller.exe,/admin,/logFile:C:\Users\XXXXXX\AppData\Local\Temp\Visual_Rust_for_Visual_Studio_2017_20170512192020_002_VSIXBootstrapper.log,C:\ProgramData\Package Cache\9864EE5369359DB622D0234B6C6B7640B949140C\VisualRust.vsix
    12.05.2017 19:20:30 - -------------------------------------------
    12.05.2017 19:20:30 - Microsoft VSIX Installer
    12.05.2017 19:20:30 - -------------------------------------------
    12.05.2017 19:20:31 - Initializing Install...
    12.05.2017 19:20:32 - Extension Details...
    12.05.2017 19:20:32 - 	Identifier         : 40c1d2b5-528b-4966-a7b1-1974e3568abe
    12.05.2017 19:20:32 - 	Name               : Visual Rust
    12.05.2017 19:20:32 - 	Author             : The Piston Project
    12.05.2017 19:20:32 - 	Version            : 0.2.0
    12.05.2017 19:20:32 - 	Description        : Visual Studio integration for the Rust programming language (http://www.rust-lang.org/)
    12.05.2017 19:20:32 - 	Locale             : en-US
    12.05.2017 19:20:32 - 	MoreInfoURL        : 
    12.05.2017 19:20:32 - 	InstalledByMSI     : True
    12.05.2017 19:20:32 - 	SupportedFrameworkVersionRange : [4.6,)
    12.05.2017 19:20:32 - 
    12.05.2017 19:20:32 - 	SignatureState     : Unsigned
    12.05.2017 19:20:32 - 	Supported Products : 
    12.05.2017 19:20:32 - 		Microsoft.VisualStudio.Community
    12.05.2017 19:20:32 - 			Version : [15.0,)
    12.05.2017 19:20:32 - 		Microsoft.VisualStudio.Pro
    12.05.2017 19:20:32 - 			Version : [15.0,)
    12.05.2017 19:20:32 - 		Microsoft.VisualStudio.Enterprise
    12.05.2017 19:20:32 - 			Version : [15.0,)
    12.05.2017 19:20:32 - 
    12.05.2017 19:20:32 - 	References         : 
    12.05.2017 19:20:32 - 	Prerequisites      : 
    12.05.2017 19:20:32 - 		-------------------------------------------------------
    12.05.2017 19:20:32 - 		Identifier   : Microsoft.VisualStudio.Component.CoreEditor
    12.05.2017 19:20:32 - 		Name         : Visual Studio core editor
    12.05.2017 19:20:32 - 		Version      : [15.0,)
    12.05.2017 19:20:32 - 
    12.05.2017 19:20:32 - 		-------------------------------------------------------
    12.05.2017 19:20:32 - 		Identifier   : Microsoft.VisualStudio.Component.VC.CoreIde
    12.05.2017 19:20:32 - 		Name         : Visual Studio C++ core features
    12.05.2017 19:20:32 - 		Version      : [15.0,16.0)
    12.05.2017 19:20:32 - 
    12.05.2017 19:20:32 - Signature Details...
    12.05.2017 19:20:32 - 	Extension is not signed.
    12.05.2017 19:20:32 - 
    12.05.2017 19:20:32 - Searching for applicable products...
    12.05.2017 19:20:32 - Found installed product - Microsoft Visual Studio Community 2015
    12.05.2017 19:20:32 - Found installed product - Microsoft Visual Studio 2015 Shell (Integrated)
    12.05.2017 19:20:32 - Found installed product - Global Location
    12.05.2017 19:20:32 - Found installed product - Visual Studio Community 2017
    12.05.2017 19:20:44 - PKGDEF Information: Looking for master PkgDef file, Path: C:\Program Files (x86)\Visual Studio\2017\Community\Common7\IDE\master.pkgdef
    
    12.05.2017 19:20:44 - PKGDEF Information: Creating PkgDefCacheNonVolatile
    12.05.2017 19:20:44 - PKGDEF Information: Double-checking master pkgdef file
    12.05.2017 19:20:44 - PKGDEF Information: PkgDefManagement initialized
    12.05.2017 19:20:44 - PKGDEF Information: RootFolder, Path: C:\Program Files (x86)\Visual Studio\2017\Community\
    
    12.05.2017 19:20:44 - PKGDEF Information: ShellFolder, Path: C:\Program Files (x86)\Visual Studio\2017\Community\
    
    12.05.2017 19:20:44 - PKGDEF Information: PkgDefSearchPath, Path: C:\Program Files (x86)\Visual Studio\2017\Community\Common7\IDE\Extensions;C:\Program Files (x86)\Visual Studio\2017\Community\Common7\IDE\CommonExtensions;C:\Program Files (x86)\Visual Studio\2017\Community\Common7\IDE\devenv.admin.pkgdef
    
    12.05.2017 19:20:44 - PKGDEF Information: ImageManifestSearchPath, Path: C:\Program Files (x86)\Visual Studio\2017\Community\Common7\IDE\Extensions;C:\Program Files (x86)\Visual Studio\2017\Community\Common7\IDE\CommonExtensions;C:\Users\Denis\AppData\Local\Microsoft\VisualStudio\15.0_69dcc73d\Extensions
    
    12.05.2017 19:20:44 - PKGDEF Information: ApplicationExtensionsFolder, Path: C:\Program Files (x86)\Visual Studio\2017\Community\Common7\IDE\Extensions
    
    12.05.2017 19:20:44 - PKGDEF Information: "ZeroImpact" = dword:0, "MergeRegistry" = dword:3
    12.05.2017 19:20:44 - PKGDEF Information: Could not find ConfigurationChanged timestamp., PKGDEF: 80070002
    12.05.2017 19:20:44 - PKGDEF Information: User extensions enabled by setting, Path: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\15.0_69dcc73d\ExtensionManager\EnableAdminExtensions
    
    12.05.2017 19:20:44 - PKGDEF Information: PkgDefCache flags, PKGDEF: 7001
    12.05.2017 19:20:44 - PKGDEF Information: Could not find ConfigurationChanged timestamp., PKGDEF: 80070002
    12.05.2017 19:20:44 - PKGDEF Information: PkgDefManagement startup complete
    12.05.2017 19:20:45 - The extension with ID '40c1d2b5-528b-4966-a7b1-1974e3568abe' is not installed to Visual Studio Community 2017.
    12.05.2017 19:20:51 - The following target products have been selected...
    12.05.2017 19:20:51 - 	Visual Studio Community 2017
    12.05.2017 19:20:51 - 
    12.05.2017 19:20:51 - Beginning to install extension to Visual Studio Community 2017...
    12.05.2017 19:20:51 - Install Error : Microsoft.VisualStudio.ExtensionManager.InstallByMsiException: The InstalledByMSI element in extension Visual Rust cannot be 'true' when installing an extension through the Extensions and Updates Installer.  The element can only be 'true' when an MSI lays down the extension manifest file.
       at Microsoft.VisualStudio.ExtensionManager.ExtensionEngineImpl.CheckForInstallBlockers(InstallableExtensionImpl extension, IInstalledExtensionList modifiedInstalledExtensionsList, Boolean isNestedExtension, InstallFlags flags, Boolean& performExtensionUpdate)
       at Microsoft.VisualStudio.ExtensionManager.ExtensionEngineImpl.InstallInternal(InstallableExtensionImpl extension, InstallFlags installFlags, IDictionary`2 extensionsInstalledSoFar, List`1 extensionsUninstalledSoFar, IInstalledExtensionList modifiedInstalledExtensionsList, AsyncOperation asyncOp, IProgress`1 progress)
       at Microsoft.VisualStudio.ExtensionManager.ExtensionEngineImpl.BeginInstall(IInstallableExtension installableExtension, InstallFlags installFlags, AsyncOperation asyncOp)
       at Microsoft.VisualStudio.ExtensionManager.ExtensionEngineImpl.InstallWorker(IInstallableExtension extension, InstallFlags installFlags, AsyncOperation asyncOp)
    
    Reply
  • Rust installation not found
    Rust installation not found

    Mar 6, 2016

    When using visual rust and compiling i always get the error message: No Rust installation detected. You can download official Rust installer from rust-lang.org/install I installed a few rust versions inclusive the msvc abi etc.. but the error keeps beeing there. I have the path set to my rust installation and the rust src env path. I use visual studio 2015. I tried with latest build of visual rust and latest stable. Can you help me with that?

    Reply
  • Build is always 'up-to-date' (MSVC)
    Build is always 'up-to-date' (MSVC)

    Mar 28, 2016

    Environment

    • Visual Studio 2015 Community Update 1
    • Rust 1.7 MSVC
    • VisualRust 0.1.2

    Repro

    1. Create a new project
    2. Run the project. Outcome: Hello World!
    3. Add the following to main: println!("Test");
    4. Optional: save main.rs.
    5. Run the project. Outcome: Hello World! Expected: Hello World!<newline>Test.
    6. Right click on the project and select Rebuild.
    7. Run the project. Outcome: as expected.

    Summary

    The build is not detecting changes to files.

    Remarks

    An older version of Visual Rust (and Rust) was installed on the environment, but uninstalled prior to installing these latest versions.

    MSBuild log

    Reply