From f59ab1748df349e7299670c9d7d615934cf42dde Mon Sep 17 00:00:00 2001 From: Emanuel Albu Date: Fri, 20 May 2022 20:10:25 +0200 Subject: [PATCH 1/3] Update Sdl.Core.PluginFramework.Build to 17.0.0 when using UpdateCommand Fix condition when references are updated --- TemplatesVSIX/MsBuild/IReference.cs | 1 + TemplatesVSIX/MsBuild/Reference.cs | 5 ++++ TemplatesVSIX/ProjectUpdateCommand.cs | 15 ++++++++--- .../Trados/Patches/ReferencePatch.cs | 26 +++++++++++-------- TemplatesVSIX/Trados/StudioWRPluginProject.cs | 2 +- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/TemplatesVSIX/MsBuild/IReference.cs b/TemplatesVSIX/MsBuild/IReference.cs index 466f0da..60897ab 100644 --- a/TemplatesVSIX/MsBuild/IReference.cs +++ b/TemplatesVSIX/MsBuild/IReference.cs @@ -7,5 +7,6 @@ internal interface IReference Include Include { get; set; } void DeleteElement(string name); + void DeleteReference(); } } diff --git a/TemplatesVSIX/MsBuild/Reference.cs b/TemplatesVSIX/MsBuild/Reference.cs index 4f4b34e..438b179 100644 --- a/TemplatesVSIX/MsBuild/Reference.cs +++ b/TemplatesVSIX/MsBuild/Reference.cs @@ -24,6 +24,11 @@ public Include Include } } + public void DeleteReference() + { + _referenceElement.Remove(); + } + public void DeleteElement(string name) { _referenceElement diff --git a/TemplatesVSIX/ProjectUpdateCommand.cs b/TemplatesVSIX/ProjectUpdateCommand.cs index b34e882..330033b 100644 --- a/TemplatesVSIX/ProjectUpdateCommand.cs +++ b/TemplatesVSIX/ProjectUpdateCommand.cs @@ -137,9 +137,18 @@ private static void UpdateDocument(XDocument document) .Descendants() .FirstOrDefault(d => d.Name.LocalName == "RequiredProduct"); - requiredProductElement.Attribute("name").Value = "TradosStudio"; - requiredProductElement.Attribute("minversion").Value = "17.0"; - requiredProductElement.Add(new XAttribute("maxversion", "17.9")); + SetAttributeValue(requiredProductElement, "name", "TradosStudio"); + SetAttributeValue(requiredProductElement, "minversion", "17.0"); + SetAttributeValue(requiredProductElement, "maxversion", "17.9"); + + } + + private static void SetAttributeValue(XElement element, string attribute, string value) + { + if (element == null) return; + + if (element.Attribute(attribute) == null) element.Add(new XAttribute(attribute, value)); + else element.Attribute(attribute).Value = value; } private static async Task GetPluginManifestAsync(string manifest) diff --git a/TemplatesVSIX/Trados/Patches/ReferencePatch.cs b/TemplatesVSIX/Trados/Patches/ReferencePatch.cs index 30162c6..48af2bb 100644 --- a/TemplatesVSIX/Trados/Patches/ReferencePatch.cs +++ b/TemplatesVSIX/Trados/Patches/ReferencePatch.cs @@ -15,13 +15,10 @@ public ReferencePatch(string newVersion) public void PatchProject(IProject project) { - if (project != null && project.References != null) - { - project.References - .Where(r => r.Include.Name.Contains("Sdl")) - .ToList() - .ForEach(UpdateHintPath); - } + project?.References + .Where(r => r.Include.Name.ToLower().Contains("sdl") || r.HintPath.ToLower().Contains("sdl")) + ?.ToList() + .ForEach(UpdateHintPath); } public void PatchPackages(IPackagesConfig packageConfig) @@ -30,11 +27,18 @@ public void PatchPackages(IPackagesConfig packageConfig) private void UpdateHintPath(IReference reference) { - reference.HintPath = - $@"$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio{_newVersion}\{reference.Include.Name}.dll"; + if (reference.HintPath.Contains("PluginFramework")) + { + reference.DeleteReference(); + } + else + { + reference.HintPath = + $@"$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio{_newVersion}\{reference.Include.Name}.dll"; - reference.DeleteElement("Private"); - reference.DeleteElement("SpecificVersion"); + reference.DeleteElement("Private"); + reference.DeleteElement("SpecificVersion"); + } } } } diff --git a/TemplatesVSIX/Trados/StudioWRPluginProject.cs b/TemplatesVSIX/Trados/StudioWRPluginProject.cs index c63b467..332beb3 100644 --- a/TemplatesVSIX/Trados/StudioWRPluginProject.cs +++ b/TemplatesVSIX/Trados/StudioWRPluginProject.cs @@ -13,7 +13,7 @@ public StudioWRPluginProject(string projectFile) new TargetFrameworkPatch("v4.8"), new ReferencePatch("17"), new DeploymentPathPatch("17"), - new PluginFrameworkPatch("2.1.0", "16.1.0") + new PluginFrameworkPatch("2.1.0", "17.0.0") ); } From 3afcfd215985c05b8d3bdf53f2c09d2d69a3b4af Mon Sep 17 00:00:00 2001 From: Emanuel Albu Date: Fri, 20 May 2022 20:11:15 +0200 Subject: [PATCH 2/3] Check for nulls Remove True --- TemplatesVSIX/MsBuild/Include.cs | 2 +- TemplatesVSIX/MsBuild/Project.cs | 11 ++++++----- .../SDL Terminology Provider/ProjectTemplate.csproj | 7 ------- .../SDL Trados Studio/ProjectTemplate.csproj | 9 --------- .../SDL Translation Provider/ProjectTemplate.csproj | 4 ---- 5 files changed, 7 insertions(+), 26 deletions(-) diff --git a/TemplatesVSIX/MsBuild/Include.cs b/TemplatesVSIX/MsBuild/Include.cs index 9901f78..34d8769 100644 --- a/TemplatesVSIX/MsBuild/Include.cs +++ b/TemplatesVSIX/MsBuild/Include.cs @@ -16,7 +16,7 @@ public Include(string includeString) if (!items.Any()) throw new ArgumentException("The include string is invalid", nameof(includeString)); - Name = items.First(); + Name = items.FirstOrDefault(); Properties = items.Skip(1) .Select(s => { diff --git a/TemplatesVSIX/MsBuild/Project.cs b/TemplatesVSIX/MsBuild/Project.cs index 52c1805..6580145 100644 --- a/TemplatesVSIX/MsBuild/Project.cs +++ b/TemplatesVSIX/MsBuild/Project.cs @@ -67,16 +67,16 @@ public string TargetVersion { return _document .Descendants() - .First(d => d.Name.LocalName == TargetFrameworkVersionText) + .FirstOrDefault(d => d.Name.LocalName == TargetFrameworkVersionText)? .Value; } set { var target = _document .Descendants() - .First(d => d.Name.LocalName == TargetFrameworkVersionText); + .FirstOrDefault(d => d.Name.LocalName == TargetFrameworkVersionText); - target.Value = value; + if (target != null) target.Value = value; } } @@ -103,8 +103,9 @@ public void AddProperty(string name, string value) { var group = _document .Descendants() - .First(d => d.Name.LocalName == PropertyGroupText && d.Attribute("Condition") == null); - group.Add(new XElement(defaultNs + name, value)); + .FirstOrDefault(d => d.Name.LocalName == PropertyGroupText && d.Attribute("Condition") == null); + + group?.Add(new XElement(defaultNs + name, value)); } } diff --git a/TemplatesVSIX/SDL Terminology Provider/ProjectTemplate.csproj b/TemplatesVSIX/SDL Terminology Provider/ProjectTemplate.csproj index 99ed47d..b3c217d 100644 --- a/TemplatesVSIX/SDL Terminology Provider/ProjectTemplate.csproj +++ b/TemplatesVSIX/SDL Terminology Provider/ProjectTemplate.csproj @@ -7,31 +7,24 @@ - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Core.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Implementation.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Core.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.Core.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.FileBased.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.Settings.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.Terminology.TerminologyProvider.Core.dll diff --git a/TemplatesVSIX/SDL Trados Studio/ProjectTemplate.csproj b/TemplatesVSIX/SDL Trados Studio/ProjectTemplate.csproj index 9e6d035..a212e52 100644 --- a/TemplatesVSIX/SDL Trados Studio/ProjectTemplate.csproj +++ b/TemplatesVSIX/SDL Trados Studio/ProjectTemplate.csproj @@ -7,39 +7,30 @@ - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.Desktop.IntegrationApi.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.Desktop.IntegrationApi.Extensions.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Core.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Implementation.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.Core.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.FileBased.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.Settings.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.TranslationStudioAutomation.IntegrationApi.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.TranslationStudioAutomation.IntegrationApi.Extensions.dll diff --git a/TemplatesVSIX/SDL Translation Provider/ProjectTemplate.csproj b/TemplatesVSIX/SDL Translation Provider/ProjectTemplate.csproj index 619c339..6685554 100644 --- a/TemplatesVSIX/SDL Translation Provider/ProjectTemplate.csproj +++ b/TemplatesVSIX/SDL Translation Provider/ProjectTemplate.csproj @@ -8,18 +8,14 @@ $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.Core.Globalization.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.LanguagePlatform.Core.dll - True - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.LanguagePlatform.TranslationMemory.dll - True $(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.LanguagePlatform.TranslationMemoryApi.dll From 1f0a1f006c4f905eafc6b8eb8d232c115ff55679 Mon Sep 17 00:00:00 2001 From: David Watson Date: Fri, 20 May 2022 21:38:41 +0100 Subject: [PATCH 3/3] Update source.extension.vsixmanifest version --- TemplatesVSIX/source.extension.vsixmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TemplatesVSIX/source.extension.vsixmanifest b/TemplatesVSIX/source.extension.vsixmanifest index 1a7c39f..a0d5560 100644 --- a/TemplatesVSIX/source.extension.vsixmanifest +++ b/TemplatesVSIX/source.extension.vsixmanifest @@ -1,7 +1,7 @@ - + Trados Studio 17 templates for Visual Studio 2022 Visual Studio templates for Trados Studio 17 Copyright © 2011 - 2022 SDL as part of the RWS Holdings Plc group of companies ("RWS Group") http://appstore.sdl.com/language/developers