LivewareIssue
LivewareIssue
CC#
Created by LivewareIssue on 7/10/2023 in #help
❔ Using Roslyn from a 'single-file' app
For long-winded reasons, I need to publish my Roslyn-powered code-indexing app as a 'single-file' deployment (for clarity, I don't mean an app with one source file, I mean an app that is published as a self-contained executable, with the .NET runtime bundled). This might sound counter-intuitive as, by definition, Roslyn needs access to the .NET SDK in order to actually analyse projects. It is guaranteed that there is a .NET install at a known path on the system i'm going to be deploying onto, however the dotnet CLI on said machine is broken (long story, not easy to fix). In theory, I should be able to point to the dotnet install with MSBuildLocator.RegisterDotNetPath (as MSBuildLocator can't find VS installs when called from a single-file app) however i'm getting different behaviour when running the self-contained version as opposed to the default build. When I run the app normally, it works correctly (i.e. can open and analyse projects). When I try to open a solution from the self-contained app, it fails with the following (not very helpful) message: One or more errors occurred. (The path is empty. (Parameter 'path')) I've validated the solution it's trying to open - if I try build the solution directly, with dotnet, it builds fine with 0 errors/warnings, but Roslyn chokes on it. I presume this must be because of the single-file deployment, but without better error messaging i'm a bit stuck. My question is: how might I go about debugging this and has anyone had success using Roslyn from a single-file app (can I include the bits of the .NET SDK required by roslyn in the single-file deployment? which bits need to be included, etc.)
36 replies