-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Update MSBuildWorkspace to work with MSBuild 15.0 #15056
Comments
Alternatively, we could try writing some code to enumerate the installed instances of 15.0 versions instead of relying on it being in the gac. |
Even better. |
@Pilchie Isn't there a NuGet package to help do that? |
See |
You're already working on this, right? |
Yep. In progress. |
I think @mattwar is working on this now. |
This is working now in dev15 RTM. You need to have the application using MSBuildWorkspace also include the Microsoft.Build and Microsoft.Build.Tasks.Core packages from nuget (both version 15.1.0-preview-000458-02 or newer) and have your app.config file include the newer msbuild redirects that can be found in the msbuild.exe.config for msbuild 15. |
@Pilchie @mattwar using msbuildworkspace throws exception with VS Enterprise 2017 version 15.3. It did work fine prior to the upgrade. I would really appreciate any help. We are using roslyin to convert the whole code base into using async -await. The exception am getting is
Program.Main var activeWorkspace = MSBuildWorkspace.Create();
activeWorkspace.WorkspaceFailed += (s, e) => { Console.WriteLine(e.Diagnostic); };
var result = activeWorkspace.OpenSolutionAsync(SolutionPath).Result; This is the app.config of the roslyn console project. <dependentAssembly>
<assemblyIdentity name="Microsoft.Build" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Utilities.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0"/>
</dependentAssembly> |
I'm pretty sure that MSBuild was reved in 15.3, and those binding redirects probably need to be updated. |
Thanks for the quick response. I added the binding redirects after looking into the |
No new binding redirects should be needed for MSBuild 15.3 compatibility (we left the assembly version the same to avoid the need for them). @sanilpaul what you're seeing sounds very similar to dotnet/msbuild#2369; let's track it there. |
@rainersigwald I appreciate your quick response. Looking forward to the fix. |
@Pilchie @rainersigwald @DustinCampbell I used the msbuild in the preview package described in dotnet/msbuild#2369 to get past the msbuild version issue. I got past the version issue described earlier in the thread. However, I am running into another issue similar to what is described in #18633. Do any of the Roslyn code analysis package have to change? Any pointers on how to proceed will be really helpful. I am stuck now. These are the error details. These are the packages I have |
I am also experiencing what @sanilpaul described (Csc task failed) and can reproduce in LinqPad with a minimal target solution (attached). I'm using released versions of the packages. |
@aggieben I got it resolved by following the last comment in dotnet/msbuild#2369 . Before creating the workspace, set the environment variable through code. Basically, you would do Environment.SetEnvironmentVariable("VSINSTALLDIR", visualStudio2017.GetInstallationPath());
Environment.SetEnvironmentVariable("VisualStudioVersion", "15.0");
var activeWorkspace = MSBuildWorkspace.Create();
activeWorkspace.WorkspaceFailed += (s, e) => { Console.WriteLine(e.Diagnostic); };
var result = activeWorkspace.OpenSolutionAsync(SolutionPath).Result; |
MSBuildWorkspace
, along with its unit tests and other tests that happen to use it, directly or indirectly depend on being able to find the location of MSBuild binaries, settings, and targets in the registry. This was fine for MSBuild 14.0, but no such information is available for 15.0 (by design).We need to update
MSBuildWorkspace
to use some sort of self-contained MSBuild-in-a-package once it exists, and updated all the related tests.Until we do this,
MSBuildWorkspace
and its tests won't be able to run on a system that only has Dev15.The text was updated successfully, but these errors were encountered: