-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Xml; | ||
|
||
namespace DevWinUI_Template; | ||
public static class Helper | ||
{ | ||
public static bool IsPreviewVSIX() | ||
{ | ||
var asm = Assembly.GetExecutingAssembly(); | ||
var asmDir = Path.GetDirectoryName(asm.Location); | ||
var manifestPath = Path.Combine(asmDir, "extension.vsixmanifest"); | ||
bool isPreview = false; | ||
if (File.Exists(manifestPath)) | ||
{ | ||
var doc = new XmlDocument(); | ||
doc.Load(manifestPath); | ||
var metaData = doc.DocumentElement.ChildNodes.Cast<XmlElement>().FirstOrDefault(x => x.Name == "Metadata"); | ||
var identity = metaData.ChildNodes.Cast<XmlElement>().FirstOrDefault(x => x.Name == "Preview"); | ||
var value = identity?.InnerText; | ||
if (!string.IsNullOrEmpty(value)) | ||
{ | ||
isPreview = value.ToLower().Equals("true"); | ||
} | ||
} | ||
return isPreview; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters