Skip to content

Commit

Permalink
Merge pull request #27 from RWS/Main_VSExtension
Browse files Browse the repository at this point in the history
Main vs extension
  • Loading branch information
rwsdwatson authored May 20, 2022
2 parents 1c8e3bb + 1f0a1f0 commit d99ff52
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 42 deletions.
1 change: 1 addition & 0 deletions TemplatesVSIX/MsBuild/IReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ internal interface IReference
Include Include { get; set; }

void DeleteElement(string name);
void DeleteReference();
}
}
2 changes: 1 addition & 1 deletion TemplatesVSIX/MsBuild/Include.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
{
Expand Down
11 changes: 6 additions & 5 deletions TemplatesVSIX/MsBuild/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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));
}
}

Expand Down
5 changes: 5 additions & 0 deletions TemplatesVSIX/MsBuild/Reference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public Include Include
}
}

public void DeleteReference()
{
_referenceElement.Remove();
}

public void DeleteElement(string name)
{
_referenceElement
Expand Down
15 changes: 12 additions & 3 deletions TemplatesVSIX/ProjectUpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<XDocument> GetPluginManifestAsync(string manifest)
Expand Down
7 changes: 0 additions & 7 deletions TemplatesVSIX/SDL Terminology Provider/ProjectTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,24 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Sdl.FileTypeSupport.Framework.Core">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Core.dll</HintPath>
</Reference>
<Reference Include="Sdl.FileTypeSupport.Framework.Implementation">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Implementation.dll</HintPath>
</Reference>
<Reference Include="Sdl.FileTypeSupport.Framework.Core">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Core.dll</HintPath>
</Reference>
<Reference Include="Sdl.ProjectAutomation.Core">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.Core.dll</HintPath>
</Reference>
<Reference Include="Sdl.ProjectAutomation.FileBased">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.FileBased.dll</HintPath>
</Reference>
<Reference Include="Sdl.ProjectAutomation.Settings">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.Settings.dll</HintPath>
</Reference>
<Reference Include="Sdl.Terminology.TerminologyProvider.Core">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.Terminology.TerminologyProvider.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
Expand Down
9 changes: 0 additions & 9 deletions TemplatesVSIX/SDL Trados Studio/ProjectTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,30 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Sdl.Desktop.IntegrationApi">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.Desktop.IntegrationApi.dll</HintPath>
</Reference>
<Reference Include="Sdl.Desktop.IntegrationApi.Extensions">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.Desktop.IntegrationApi.Extensions.dll</HintPath>
</Reference>
<Reference Include="Sdl.FileTypeSupport.Framework.Core">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Core.dll</HintPath>
</Reference>
<Reference Include="Sdl.FileTypeSupport.Framework.Implementation">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.FileTypeSupport.Framework.Implementation.dll</HintPath>
</Reference>
<Reference Include="Sdl.ProjectAutomation.Core">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.Core.dll</HintPath>
</Reference>
<Reference Include="Sdl.ProjectAutomation.FileBased">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.FileBased.dll</HintPath>
</Reference>
<Reference Include="Sdl.ProjectAutomation.Settings">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.ProjectAutomation.Settings.dll</HintPath>
</Reference>
<Reference Include="Sdl.TranslationStudioAutomation.IntegrationApi">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.TranslationStudioAutomation.IntegrationApi.dll</HintPath>
</Reference>
<Reference Include="Sdl.TranslationStudioAutomation.IntegrationApi.Extensions">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.TranslationStudioAutomation.IntegrationApi.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
Expand Down
4 changes: 0 additions & 4 deletions TemplatesVSIX/SDL Translation Provider/ProjectTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
<ItemGroup>
<Reference Include="Sdl.Core.Globalization">
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.Core.Globalization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sdl.LanguagePlatform.Core">
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.LanguagePlatform.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Sdl.LanguagePlatform.TranslationMemory">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.LanguagePlatform.TranslationMemory.dll</HintPath>
</Reference>
<Reference Include="Sdl.LanguagePlatform.TranslationMemoryApi">
<Private>True</Private>
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.LanguagePlatform.TranslationMemoryApi.dll</HintPath>
</Reference>
<Reference Include="System" />
Expand Down
26 changes: 15 additions & 11 deletions TemplatesVSIX/Trados/Patches/ReferencePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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");
}
}
}
}
2 changes: 1 addition & 1 deletion TemplatesVSIX/Trados/StudioWRPluginProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
}

Expand Down
2 changes: 1 addition & 1 deletion TemplatesVSIX/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="3D390539-4A5C-4A0E-AAF8-2BCD8EA83FF1" Version="17.0.01" Language="en-US" Publisher="RWS" />
<Identity Id="3D390539-4A5C-4A0E-AAF8-2BCD8EA83FF1" Version="17.0.2" Language="en-US" Publisher="RWS" />
<DisplayName>Trados Studio 17 templates for Visual Studio 2022</DisplayName>
<Description xml:space="preserve">Visual Studio templates for Trados Studio 17 Copyright © 2011 - 2022 SDL as part of the RWS Holdings Plc group of companies ("RWS Group")</Description>
<MoreInfo>http://appstore.sdl.com/language/developers</MoreInfo>
Expand Down

0 comments on commit d99ff52

Please sign in to comment.