Skip to content
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

MissingMethodException UnconfiguredProject.get_Services() in VS2019 when referencing ProjectSystem.15 #4608

Closed
MBulli opened this issue Feb 23, 2019 · 5 comments

Comments

@MBulli
Copy link

MBulli commented Feb 23, 2019

Visual Studio Version: VS2019 Preview 3

Summary:
Our extension fails to build in VS2019. We reference Microsoft.VisualStudio.ProjectSystem, Microsoft.VisualStudio.ProjectSystem.Managed and Microsoft.VisualStudio.ProjectSystem.VS all with version 15 because we still want to support VS2017. But we can't build the extension because ProjectSystem depends on Microsoft.Build assemblies which are targeting .Net framework 4.7. I don't know whether we do something wrong or it's a problem with VS2019.

Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem.Managed, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem.VS, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem.VS, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem.VS, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem.VS, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem.Managed, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem.Managed, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem.Managed, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".
Warning		The primary reference "Microsoft.VisualStudio.ProjectSystem, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.6".			

Steps to Reproduce:
Happens as soon as we try to build our extension in VS2019.

Expected Behavior:
Shouldn't visual studio assembly references be backwards compatible? I expected that VS2019 redirects the references to v16 assemblies which should work silently.

Actual Behavior:
Build fails because our extension targets .Net framework 4.6 but Microsoft.Build assemblies target 4.7.

User Impact:
We would need to build one assembly targeting VS2017 and one for VS2019 but sharing the same code.

@jmarolf
Copy link
Contributor

jmarolf commented Feb 23, 2019

@MBulli Microsoft.MSBuild from nuget is built against .NET Framework 4.6 so it's unclear how this is happening unless you are building your project against whatever MSBuild happens to be installed on the machine. Is that the case?

@MBulli
Copy link
Author

MBulli commented Feb 23, 2019

Yes you're right, we weren't using the Nuget version. That fixed the warning. Thanks, silly mistake!

@MBulli MBulli closed this as completed Feb 23, 2019
@MBulli
Copy link
Author

MBulli commented Feb 23, 2019

Okay after fixing the wrong MSBuild references our extension still won't work.
We're still targeting ProjectSystem v15.
When we try to obtain the command args of the current project this code fails with the following exception:

IVsBrowseObjectContext context = project as IVsBrowseObjectContext;
var launchSettingsProvider = context.UnconfiguredProject.Services.ExportProvider.GetExportedValue<ILaunchSettingsProvider>();

Method not found: 'Microsoft.VisualStudio.ProjectSystem.IUnconfiguredProjectServices Microsoft.VisualStudio.ProjectSystem.UnconfiguredProject.get_Services()'.

This only happens in VS2019 and if I update the Nuget reference to ProjectSystem.16.0.374-pre it works again. Is this expected behavior or am I'm missing something obvious again?

@MBulli MBulli reopened this Feb 23, 2019
@MBulli MBulli changed the title Vsix extension fails to build in VS2019 referencing ProjectSystem v15 MissingMethodException UnconfiguredProject.get_Services() in VS2019 when referencing ProjectSystem.15 Feb 23, 2019
@jmarolf
Copy link
Contributor

jmarolf commented Feb 23, 2019

This was an intentional breaking change by the VS team. Microsoft.VisualStudio.ProjectSystem.UnconfiguredProject.Services now returns the class UnconfiguredProjectServices instread of the interface IUnconfiguredProjectServices. To have your extension work in both VS 2017 and VS 2019 you will likely need to use reflection.

@MBulli
Copy link
Author

MBulli commented Feb 24, 2019

Again, thank you for the quick help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants