Skip to content

Compilation and debugging

Marek Linka edited this page Dec 21, 2016 · 1 revision

Compiling and running the code

Compilation

Steps necessary to compile the Agent Mulder extension:

  1. Clone the repo/download it as ZIP (duh)
  2. Open the solution, hit Build for the whole solution
  3. Wait for NuGet packages to download (this might take some time)
  4. ???
  5. Profit

Building the NuGet

After this, you should end up with all the binaries you need. After you compile, you can run nuget.exe to produce an actual NuGet package that can be installed into a compatible ReSharper version. Steps to produce the NuGet package:

  1. Compile the solution (Debug or Release, both will work)
  2. Run the buildNuget.ps1 script (located in src/). You need to provide three arguments to the script
  • -version - the version of the extension you are packaging (e.g. 2016.3)
  • -waveVersion - the wave version the extension is compatible with (see here for details)
  • -config - the configuration you compiled for that you wish to package (either Debug or Release)
  1. The resulting package will be located in /src/nuget

Live Debugging

Now comes the fun part. The code can actually be debugged directly from Visual Studio. Unfortunately, because of ReSharper platform limitations, it's not as simple as hitting F5 and sitting back. Nevertheless here's the rundown:

First of all, you will need a Visual Studio experimental instance (also knows as experimental hive). If you don't know what that is, you can find some details here. Agent Mulder solution is hard-coded to use the AgentMulder hive, so just run

devenv /rootsuffix AgentMulder

This will start a new instance of Visual Studio, completely independent of the standard instance you use for work. Next, you need to install ReSharper (whatever version you plan on compiling against) into this experimental instance. Shut down the experimental instance and run the ReSharper installer.

In the installer window click the Options button and you should see a text box called Experimental Hive. Insert AgentMulder into it (the combo might and might not recognize that the hive already exists. If not, just write it in manually). Go back and finish the installation normally.

After the installation is complete, verify that everything worked as expected by running

devenv /rootsuffix AgentMulder

again and checking if ReSharper loads up in the experimental VS instance. If everything checks out, you can register your nuget in the experimental instance. This is required and you can find instructions on how to do it here.

After the extension installer finishes, restart the experimental instance and check that you can see the Agent Mulder extension as installed.

This completes the complicated portion of our programming! You can kill the experimental instance now and come back to your regular VS.

The AgentMulder.ReSharper.Plugin project is configured to take the compilation result and copy it over to the experimental instance. It is also configured to start the experimental instance of VS when you run it, so just set it as your solution's startup project, hit Run, and watch it do its thing.

If everything works as expected, you should now be able to debug the extensions just by hitting Run. There are some conditions, though.

Important notice for debugging

  1. You MUST first install the extension from a NuGet package manually. This will register the package with ReSharper.
  2. After this registration, the automatic copy should be sufficient to provide you with debugging capabilities, no need to repeat the whole registration process.
  3. However, if you add a new binary file (e.g. a support for new DI container) or some other important information about the package changes, you need to repeat the registration with an updated NuGet package. See details here (first few paragraphs).

And that's it. You should now be able to compile, run, and debug the code in comfort.

Clone this wiki locally