/// <summary> /// Builds the URI for the given template based on the containing project VSIX manifest identifier. /// </summary> internal static Uri BuildUri(IItemContainer selectedItem) { var manifest = selectedItem.GetToolkitManifest(); var owningProject = selectedItem.Traverse(x => x.Parent, item => item.Kind == ItemKind.Project); tracer.Info(Properties.Resources.TextTemplateUriEditor_TraceReadingManifest, manifest.GetLogicalPath()); string vsixId; try { vsixId = Vsix.ReadManifestIdentifier(manifest.PhysicalPath); } catch (Exception e) { tracer.Error(e, String.Format(CultureInfo.CurrentCulture, Properties.Resources.TextTemplateUriEditor_TraceReadingManifestFailed, manifest.GetLogicalPath())); throw; } var path = GetLogicalPath(selectedItem).Replace(owningProject.GetLogicalPath(), string.Empty); // Use alternative name if IncludeInVSIXAs defined var templateItem = (IItem)selectedItem; if (IsIncludeInVSIXAs(templateItem)) { path = Path.Combine(Path.GetDirectoryName(path), templateItem.Data.IncludeInVSIXAs); } return(new Uri(new Uri(TextTemplateUri.UriHostPrefix), new Uri(vsixId + path, UriKind.Relative))); }
public void Initialize() { var deployedVsixItemPath = Path.Combine(this.TestContext.DeploymentDirectory, this.DeployedVsixItemPath); this.VsixInfo = Vsix.ReadManifest(deployedVsixItemPath); // Unzip VSIX content to target dir this.TargetDir = new DirectoryInfo("Target").FullName; Vsix.Unzip(deployedVsixItemPath, this.TargetDir); this.VsixIdentifier = Vsix.ReadManifestIdentifier(Path.Combine(this.TargetDir, "extension.vsixmanifest")); }
public void WhenReadingManifestId_ThenGetsIdentifier() { var extension = Vsix.ReadManifestIdentifier("Common.IntegrationTests.Content\\GivenAVsixManifestFile\\extension.vsixmanifest"); Assert.Equal("ef4561f7-a3ea-4666-a080-bc2f195451e3", extension); }