diff --git a/src/Squirrel/ShellFile.cs b/src/Squirrel/ShellFile.cs
index c69214245..1564fb334 100644
--- a/src/Squirrel/ShellFile.cs
+++ b/src/Squirrel/ShellFile.cs
@@ -1053,6 +1053,18 @@ ushort timeOut
this.shortcutFile = linkFile;
}
}
+
+ ///
+ /// Indicates whether the target is in the given directory.
+ ///
+ /// The directory.
+ /// true if the target is in the given directory; otherwise, false.
+ internal bool IsTargetInDirectory(
+ string directory)
+ {
+ return System.IO.Path.GetDirectoryName(Target)
+ .Equals(directory, StringComparison.OrdinalIgnoreCase);
+ }
}
///
diff --git a/src/Squirrel/UpdateManager.ApplyReleases.cs b/src/Squirrel/UpdateManager.ApplyReleases.cs
index 09af8c54b..ff6e6b18b 100644
--- a/src/Squirrel/UpdateManager.ApplyReleases.cs
+++ b/src/Squirrel/UpdateManager.ApplyReleases.cs
@@ -451,7 +451,7 @@ void fixPinnedExecutables(SemanticVersion newCurrentVersion, bool removeAll = fa
try {
if (shortcut == null) continue;
if (String.IsNullOrWhiteSpace(shortcut.Target)) continue;
- if (!shortcut.Target.StartsWith(rootAppDirectory, StringComparison.OrdinalIgnoreCase)) continue;
+ if (!shortcut.IsTargetInDirectory(rootAppDirectory)) continue;
if (removeAll) {
Utility.DeleteFileHarder(shortcut.ShortCutFile);
diff --git a/test/ShellLinkTests.cs b/test/ShellLinkTests.cs
new file mode 100644
index 000000000..74af97fb7
--- /dev/null
+++ b/test/ShellLinkTests.cs
@@ -0,0 +1,23 @@
+using Squirrel.Shell;
+using Xunit;
+
+namespace Squirrel.Tests
+{
+ public class ShellLinkTests
+ {
+ [Theory]
+ [InlineData(@"C:\MyApp\MyApp.exe", @"C:\MyApp", true)]
+ [InlineData(@"C:\MyApp\MyApp.exe", @"C:\MyAppTwo", false)]
+ public void IsTargetInDirectoryTest(
+ string target,
+ string directory,
+ bool isTargetInDirectory)
+ {
+ var shellLink = new ShellLink
+ {
+ Target = target
+ };
+ Assert.Equal(isTargetInDirectory, shellLink.IsTargetInDirectory(directory));
+ }
+ }
+}
diff --git a/test/Squirrel.Tests.csproj b/test/Squirrel.Tests.csproj
index 6c89f4fb3..8be9bfb40 100644
--- a/test/Squirrel.Tests.csproj
+++ b/test/Squirrel.Tests.csproj
@@ -96,6 +96,7 @@
+