Open jzielnik opened 6 years ago
We recommend that you use the Microsoft.Build.Locator
package to avoid this and other mismatched-engine-and-targets problems. There is documentation available at https://docs.microsoft.com/en-us/visualstudio/msbuild/updating-an-existing-application.
The only workaround I can think of is to copy the higher version of MSBuild assemblies over the lower version redistributed with your application. That's a pain but has worked before.
I am experiencing the same issue. Isn't it a problem with versioning policy that minor releases are introducing breaking changes? It makes Microsoft.Build API not reliable. Currently, there are many updates for VS which are released really often, should I expect that each of them can break my integration with Microsoft.Build?
@rainersigwald Microsoft.Build.Locator
has limitations - strongest of them is lack of compability with Microsoft.Build.* assemblies (older version of them required by my solution which has some projects targeted to pre-4.6 .NET Framework). Also, to my best knowledge Microsoft.Build.Locator
works properly only with VS/BuildTools 15.x. Requirement for me is version 11.0+.
Also, copying assemblies is not the case as well, because there are conflicts between dependant assemblies versions (e.g. System.Collections.Immutable is commonly used as a reference in my pre-4.6 projects).
Is there any other solution? Is there at least a way to downgrade to 15.7 after 15.8 was installed?
@tobyash86: See https://docs.microsoft.com/en-us/visualstudio/productinfo/installing-an-earlier-release-of-vs2017. This does not cover the Express edition.
Thanks @chm-tm, although I had hope that there is an easier way to do this.
Since I only depend on Visual Studio 15.8, a.k.a latest-greatest, I could resolve the issue by updating the NuGet packages from from 15.6.82 to 15.8.166.
There is still a pit-fall here: We use Professional and Express, which led to different binding redirects. In my case of a project targeting .NET 4.6.1, for System.IO.Compression
and System.Runtime.InteropServices.RuntimeInformation
.
So, this is clearly less robust than the recommended Microsoft.Build.Locator
way.
So the lesson here is do not trust Visual Studio upgrades!?
Steps to reproduce
Using Microsoft.Build package (from NuGet in version 15.6.82) added as NuGet reference to a project. Calling constructor of: Microsoft.Build.Evaluation.Project(projectFile) in one of methods. Results in throwing Microsoft.Build.Exceptions.InvalidProjectFileException Stack Trace:
Unfortunately, because product is already released it's hard to fix existing issue. Users who updated their VS2017 to version 15.8.0+ will suffer from not being able to use product.
Is there any workaround?
Expected behavior
Using this constructor should be backward compatible even if user has Microsoft.Build in version older than 15.8.X
Actual behavior
Throws an exception because usage of newly added method which was not present in older version.
Environment data
MSBuild version: Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved.
15.8.166.59604
VS2017 version: Version 15.8.1