From d8f490b4571aeb58f289bb35ee8f3693c940df96 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 5 Jun 2019 22:55:41 +0200 Subject: [PATCH] Updates to support Visual Studio 2019 --- IceBuilder/DocumentEventHandler.cs | 4 + IceBuilder/Package.cs | 10 +- IceBuilder/packages.config | 2 +- IceBuilder_Common/IVsProjectExtension.cs | 10 +- IceBuilder_Common/MSProjectExtension.cs | 18 +- IceBuilder_Common/NuGetI.cs | 14 +- IceBuilder_Common/ProjectHelperI.cs | 3 +- IceBuilder_VS2019/IceBuilder_VS2019.csproj | 182 ++++++++++++++------- IceBuilder_VS2019/app.config | 34 +++- IceBuilder_VS2019/packages.config | 84 ++++++---- README.md | 8 +- Sign.targets | 4 +- 12 files changed, 252 insertions(+), 121 deletions(-) diff --git a/IceBuilder/DocumentEventHandler.cs b/IceBuilder/DocumentEventHandler.cs index a351b76..bcb7c28 100644 --- a/IceBuilder/DocumentEventHandler.cs +++ b/IceBuilder/DocumentEventHandler.cs @@ -248,6 +248,10 @@ public int OnAfterAddFilesEx(int projectsLength, int filesLength, IVsProject[] p } } } + catch (OperationCanceledException) + { + // Ignore, this could happen if the project is reloaded + } catch (Exception ex) { Package.UnexpectedExceptionWarning(ex); diff --git a/IceBuilder/Package.cs b/IceBuilder/Package.cs index b50d84c..d4111b8 100644 --- a/IceBuilder/Package.cs +++ b/IceBuilder/Package.cs @@ -444,7 +444,7 @@ public void InitializeProject(IVsProject project) } else { - if (project is IVsAggregatableProject) + if (project is IVsAggregatableProject && !project.HasProjectFlavor(IceBuilderNewFlavor)) { project.AddProjectFlavorIfNotExists(IceBuilderNewFlavor); } @@ -584,13 +584,7 @@ private void PackageInstalled() var projects = DTEUtil.GetProjects(); foreach (IVsProject project in projects) { - // Projects that are not being track has not been previous initialized - // initialize will do nothing if zeroc.icebuilder.msbuild package is - // not installed - if(project.IsMSBuildIceBuilderInstalled()) - { - InitializeProject(project); - } + InitializeProject(project); } } diff --git a/IceBuilder/packages.config b/IceBuilder/packages.config index 9db4f72..624b8e9 100644 --- a/IceBuilder/packages.config +++ b/IceBuilder/packages.config @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/IceBuilder_Common/IVsProjectExtension.cs b/IceBuilder_Common/IVsProjectExtension.cs index 4640e34..d4a275b 100644 --- a/IceBuilder_Common/IVsProjectExtension.cs +++ b/IceBuilder_Common/IVsProjectExtension.cs @@ -193,13 +193,21 @@ public static void SetItemMetadata(this IVsProject project, string name, string ProjectFactoryHelperInstance.ProjectHelper.SetItemMetadata(project, name, value); } + public static bool HasProjectFlavor(this IVsProject project, string flavor) + { + return project.WithProject((MSProject msproject) => + { + return msproject.HasProjectFlavor(flavor); + }, true); + } + public static void AddProjectFlavorIfNotExists(this IVsProject project, string flavor) { ProjectFactoryHelperInstance.ProjectHelper.UpdateProject(project, (MSProject msproject) => { msproject.AddProjectFlavorIfNotExists(flavor); - }); + }, true); } public static void RemoveGeneratedItemCustomMetadata(this IVsProject project, List paths) diff --git a/IceBuilder_Common/MSProjectExtension.cs b/IceBuilder_Common/MSProjectExtension.cs index dff4b51..9d1e34e 100644 --- a/IceBuilder_Common/MSProjectExtension.cs +++ b/IceBuilder_Common/MSProjectExtension.cs @@ -13,14 +13,14 @@ namespace IceBuilder { public static class MSProjectExtension { - static readonly ProjectCollection cppProjectColletion = new ProjectCollection(); - public static Project LoadedProject(string path) { - return ProjectCollection.GlobalProjectCollection.GetLoadedProjects(path).FirstOrDefault(); + return ProjectCollection.GlobalProjectCollection.GetLoadedProjects(path).FirstOrDefault() ?? + ProjectCollection.GlobalProjectCollection.LoadProject(path); } - public static string GetItemMetadata(this Project project, string identity, string name, string defaultValue = "") + public static string GetItemMetadata(this Project project, string identity, string name, + string defaultValue = "") { var item = project.AllEvaluatedItems.FirstOrDefault( i => i.ItemType.Equals("SliceCompile") && i.EvaluatedInclude.Equals(identity)); @@ -34,7 +34,8 @@ public static string GetItemMetadata(this Project project, string identity, stri } } - public static string GetDefaultItemMetadata(this Project project, string name, bool evaluated, string defaultValue = "") + public static string GetDefaultItemMetadata(this Project project, string name, bool evaluated, + string defaultValue = "") { var meta = project.AllEvaluatedItemDefinitionMetadata.LastOrDefault( m => m.ItemType.Equals("SliceCompile") && m.Name.Equals(name)); @@ -208,6 +209,13 @@ public static void SetProperty(this Project project, string name, string value, } } + public static bool HasProjectFlavor(this Project project, string flavor) + { + var property = project.Xml.Properties.FirstOrDefault( + p => p.Name.Equals("ProjectTypeGuids", StringComparison.CurrentCultureIgnoreCase)); + return property != null && property.Value.IndexOf(flavor) != -1; + } + public static void AddProjectFlavorIfNotExists(this Project project, string flavor) { var property = project.Xml.Properties.FirstOrDefault( diff --git a/IceBuilder_Common/NuGetI.cs b/IceBuilder_Common/NuGetI.cs index f039c94..b006341 100644 --- a/IceBuilder_Common/NuGetI.cs +++ b/IceBuilder_Common/NuGetI.cs @@ -42,7 +42,19 @@ public NuGetI() PackageInstaller = model.GetService(); PackageRestorer = model.GetService(); PackageInstallerEvents = model.GetService(); - PackageInstallerEvents.PackageInstalled += PackageInstallerEvents_PackageInstalled; + PackageInstallerEvents.PackageReferenceAdded += PackageInstallerEvents_PackageReferenceAdded; + } + + private void PackageInstallerEvents_PackageReferenceAdded(IVsPackageMetadata metadata) + { + ThreadHelper.JoinableTaskFactory.Run(async () => + { + await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); + if (BatchEnd != null) + { + BatchEnd(); + } + }); } public bool IsPackageInstalled(EnvDTE.Project project, string packageId) diff --git a/IceBuilder_Common/ProjectHelperI.cs b/IceBuilder_Common/ProjectHelperI.cs index 0c8f91a..cb6f407 100644 --- a/IceBuilder_Common/ProjectHelperI.cs +++ b/IceBuilder_Common/ProjectHelperI.cs @@ -75,7 +75,8 @@ public void UpdateProject(IVsProject project, Action action, bool swi } protected static async Task - WithProjectAsync(UnconfiguredProject unconfiguredProject, Func func, bool switchToMainThread = false) + WithProjectAsync(UnconfiguredProject unconfiguredProject, Func func, + bool switchToMainThread = false) { T result = default(T); var service = unconfiguredProject.ProjectService.Services.ProjectLockService; diff --git a/IceBuilder_VS2019/IceBuilder_VS2019.csproj b/IceBuilder_VS2019/IceBuilder_VS2019.csproj index d80d0cd..d21707c 100644 --- a/IceBuilder_VS2019/IceBuilder_VS2019.csproj +++ b/IceBuilder_VS2019/IceBuilder_VS2019.csproj @@ -33,44 +33,43 @@ 4 - - ..\packages\VSSDK.DTE.7.0.4\lib\net20\envdte.dll - False - False + + ..\packages\EnvDTE.8.0.2\lib\net10\EnvDTE.dll + True - ..\packages\EnvDTE80.8.0.1\lib\net10\EnvDTE80.dll + ..\packages\EnvDTE80.8.0.3\lib\net10\EnvDTE80.dll True - ..\packages\Microsoft.Build.15.8.166\lib\net46\Microsoft.Build.dll + ..\packages\Microsoft.Build.16.0.461\lib\net472\Microsoft.Build.dll - ..\packages\Microsoft.Build.Framework.15.8.166\lib\net46\Microsoft.Build.Framework.dll + ..\packages\Microsoft.Build.Framework.16.0.461\lib\net472\Microsoft.Build.Framework.dll - ..\packages\Microsoft.Build.Tasks.Core.15.8.166\lib\net46\Microsoft.Build.Tasks.Core.dll + ..\packages\Microsoft.Build.Tasks.Core.16.0.461\lib\net472\Microsoft.Build.Tasks.Core.dll - ..\packages\Microsoft.Build.Utilities.Core.15.8.166\lib\net46\Microsoft.Build.Utilities.Core.dll + ..\packages\Microsoft.Build.Utilities.Core.16.0.461\lib\net472\Microsoft.Build.Utilities.Core.dll - ..\packages\Microsoft.VisualStudio.ComponentModelHost.16.0.189-g83e7c53a57\lib\net46\Microsoft.VisualStudio.ComponentModelHost.dll + ..\packages\Microsoft.VisualStudio.ComponentModelHost.16.1.89\lib\net46\Microsoft.VisualStudio.ComponentModelHost.dll - - ..\packages\Microsoft.VisualStudio.Composition.15.8.98\lib\net46\Microsoft.VisualStudio.Composition.dll + + ..\packages\Microsoft.VisualStudio.Composition.16.1.8\lib\net46\Microsoft.VisualStudio.Composition.dll - - ..\packages\Microsoft.VisualStudio.Composition.NetFxAttributes.15.8.98\lib\net45\Microsoft.VisualStudio.Composition.NetFxAttributes.dll + + ..\packages\Microsoft.VisualStudio.Composition.NetFxAttributes.16.1.8\lib\net45\Microsoft.VisualStudio.Composition.NetFxAttributes.dll - - ..\packages\Microsoft.VisualStudio.CoreUtility.15.6.27740\lib\net46\Microsoft.VisualStudio.CoreUtility.dll + + ..\packages\Microsoft.VisualStudio.CoreUtility.16.1.89\lib\net472\Microsoft.VisualStudio.CoreUtility.dll - ..\packages\Microsoft.VisualStudio.ImageCatalog.16.0.28316-pre\lib\net45\Microsoft.VisualStudio.ImageCatalog.dll + ..\packages\Microsoft.VisualStudio.ImageCatalog.16.1.28916.169\lib\net45\Microsoft.VisualStudio.ImageCatalog.dll - ..\packages\Microsoft.VisualStudio.Imaging.16.0.28316-pre\lib\net45\Microsoft.VisualStudio.Imaging.dll + ..\packages\Microsoft.VisualStudio.Imaging.16.1.28917.181\lib\net45\Microsoft.VisualStudio.Imaging.dll ..\packages\Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime.14.3.26930\lib\net20\Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime.dll @@ -94,10 +93,10 @@ True - ..\packages\Microsoft.VisualStudio.Shell.15.0.16.0.28316-pre\lib\net45\Microsoft.VisualStudio.Shell.15.0.dll + ..\packages\Microsoft.VisualStudio.Shell.15.0.16.1.28917.181\lib\net45\Microsoft.VisualStudio.Shell.15.0.dll - ..\packages\Microsoft.VisualStudio.Shell.Framework.16.0.28315-pre\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll + ..\packages\Microsoft.VisualStudio.Shell.Framework.16.1.28917.181\lib\net45\Microsoft.VisualStudio.Shell.Framework.dll ..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6072\lib\net11\Microsoft.VisualStudio.Shell.Interop.dll @@ -136,8 +135,8 @@ ..\packages\VSSDK.TemplateWizardInterface.12.0.4\lib\net20\Microsoft.VisualStudio.TemplateWizardInterface.dll False - - ..\packages\Microsoft.VisualStudio.Text.Data.15.6.27740\lib\net46\Microsoft.VisualStudio.Text.Data.dll + + ..\packages\Microsoft.VisualStudio.Text.Data.16.1.89\lib\net472\Microsoft.VisualStudio.Text.Data.dll ..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6071\lib\net11\Microsoft.VisualStudio.TextManager.Interop.dll @@ -145,8 +144,11 @@ ..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50728\lib\net11\Microsoft.VisualStudio.TextManager.Interop.8.0.dll - - ..\packages\Microsoft.VisualStudio.Threading.15.8.132\lib\net46\Microsoft.VisualStudio.Threading.dll + + ..\packages\Microsoft.VisualStudio.Threading.16.0.102\lib\net46\Microsoft.VisualStudio.Threading.dll + + + ..\packages\Microsoft.VisualStudio.Utilities.16.1.28917.181\lib\net46\Microsoft.VisualStudio.Utilities.dll ..\packages\Microsoft.VisualStudio.Validation.15.3.58\lib\net45\Microsoft.VisualStudio.Validation.dll @@ -154,58 +156,94 @@ True - - ..\packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll + + ..\packages\Nerdbank.Streams.2.2.26\lib\net472\Nerdbank.Streams.dll - - ..\packages\NuGet.VisualStudio.4.9.2\lib\net46\NuGet.VisualStudio.dll + + ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + + + ..\packages\NuGet.VisualStudio.5.1.0\lib\net472\NuGet.VisualStudio.dll True - ..\packages\VSSDK.DTE.7.0.4\lib\net20\stdole.dll - False - False + ..\packages\stdole.7.0.3303\lib\net10\stdole.dll + True - - ..\packages\StreamJsonRpc.1.3.23\lib\net45\StreamJsonRpc.dll + + ..\packages\StreamJsonRpc.2.1.6-alpha\lib\net472\StreamJsonRpc.dll - - ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + ..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.1.6.0-preview5.19224.8\lib\netstandard2.0\System.Collections.Immutable.dll - - ..\packages\System.Composition.AttributedModel.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + + ..\packages\System.Composition.AttributedModel.1.3.0-preview5.19224.8\lib\netstandard2.0\System.Composition.AttributedModel.dll - - ..\packages\System.Composition.Convention.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + + ..\packages\System.Composition.Convention.1.3.0-preview5.19224.8\lib\netstandard2.0\System.Composition.Convention.dll - - ..\packages\System.Composition.Hosting.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + + ..\packages\System.Composition.Hosting.1.3.0-preview5.19224.8\lib\netstandard2.0\System.Composition.Hosting.dll - - ..\packages\System.Composition.Runtime.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + + ..\packages\System.Composition.Runtime.1.3.0-preview5.19224.8\lib\netstandard2.0\System.Composition.Runtime.dll - - ..\packages\System.Composition.TypedParts.1.0.31\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + + ..\packages\System.Composition.TypedParts.1.3.0-preview5.19224.8\lib\netstandard2.0\System.Composition.TypedParts.dll + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll True True - + + ..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll + + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + ..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll + True + True + + + ..\packages\System.Net.WebSockets.4.3.0\lib\net46\System.Net.WebSockets.dll + True + True + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + - - ..\packages\System.Reflection.Metadata.1.3.0\lib\portable-net45+win8\System.Reflection.Metadata.dll + + ..\packages\System.Reflection.Metadata.1.7.0-preview5.19224.8\lib\netstandard2.0\System.Reflection.Metadata.dll + + + ..\packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll @@ -214,8 +252,34 @@ - - ..\packages\System.Threading.Tasks.Dataflow.4.5.24\lib\portable-net45+win8+wpa81\System.Threading.Tasks.Dataflow.dll + + ..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + ..\packages\System.Threading.Tasks.Dataflow.4.6.0\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll @@ -252,27 +316,29 @@ + - + + - + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + - - + + + \ No newline at end of file diff --git a/IceBuilder_VS2019/app.config b/IceBuilder_VS2019/app.config index 01e5242..4d9d8ba 100644 --- a/IceBuilder_VS2019/app.config +++ b/IceBuilder_VS2019/app.config @@ -4,11 +4,11 @@ - + - + @@ -20,11 +20,11 @@ - + - + @@ -52,7 +52,7 @@ - + @@ -66,6 +66,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IceBuilder_VS2019/packages.config b/IceBuilder_VS2019/packages.config index 8e5cc89..2b4dd01 100644 --- a/IceBuilder_VS2019/packages.config +++ b/IceBuilder_VS2019/packages.config @@ -1,24 +1,24 @@  - - - - - - - - - - - - + + + + + + + + + + + + - + - - + + @@ -28,30 +28,46 @@ - + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + + + + + + + + - + + + + + + + diff --git a/README.md b/README.md index 62914fc..9d541aa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Ice Builder for Visual Studio is a Visual Studio extension that configures [Ice Builder for MSBuild](https://github.com/zeroc-ice/ice-builder-msbuild) for your C++ and C# projects, all within the Visual Studio IDE. It serves as a front-end for Ice Builder for MSBuild: all the build-time processing is performed by Ice Builder for MSBuild. -Ice Builder for Visual Studio is compatible with Visual Studio 2017 or 2019, and works best with the following Ice installations: +Ice Builder for Visual Studio is compatible with Visual Studio 2015, 2017 or 2019, and works best with the following Ice installations: * Ice NuGet package for Ice 3.7 or greater ## Contents @@ -168,19 +168,17 @@ Ice Builder no longer supports direct migration from the old Ice add-in for Visu ### Build Requirements -You need Visual Studio 2017 +You need Visual Studio 2019 **AND** to install ALL of the following Visual Studio SDKs: -- [Visual Studio 2012 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=30668) -- [Visual Studio 2013 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=40758) - [Visual Studio 2015 SDK](https://msdn.microsoft.com/en-us/library/bb166441.aspx) - [Visual Studio 2017 SDK](https://docs.microsoft.com/en-us/visualstudio/extensibility/installing-the-visual-studio-sdk) ### Build Instructions -Open the `IceBuilder.sln` solution file in Visual Studio 2017. +Open the `IceBuilder.sln` solution file in Visual Studio 2019. After building the Ice Builder extension, the VSIX package will be placed in the build output directory: `IceBuilder\bin\Debug\IceBuilder.vsix` for debug builds, and `IceBuilder\bin\Release\IceBuilder.vsix` diff --git a/Sign.targets b/Sign.targets index f57862b..99fb8a1 100644 --- a/Sign.targets +++ b/Sign.targets @@ -4,7 +4,7 @@ http://timestamp.verisign.com/scripts/timstamp.dll $(WindowsSDK80Path)bin\x86\signtool.exe "$(SignToolPath)" sign /f "$(SIGN_CERTIFICATE)" /p $(SIGN_PASSWORD) /t $(TimeStampServer) - $(MSBuildThisFileDirectory)packages\Microsoft.VSSDK.Vsixsigntool.15.9.28307\tools\vssdk\vsixsigntool.exe - $(VsixSignTool) sign /f $(SIGN_CERTIFICATE) /p $(SIGN_PASSWORD) /fd sha1 + $(MSBuildThisFileDirectory)packages\Microsoft.VSSDK.Vsixsigntool.16.1.28916.169\tools\vssdk\vsixsigntool.exe + $(VsixSignTool) sign /f $(SIGN_CERTIFICATE) /p $(SIGN_PASSWORD) /fd sha256