Skip to content

Commit 7586201

Browse files
committed
Adde dkilling any running instance of services when doing dependency updates.
1 parent b7c45ba commit 7586201

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

src/CSScriptNpp/CSScriptNpp.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@
399399
</ItemGroup>
400400
<ItemGroup />
401401
<PropertyGroup>
402-
<PostBuildEvent>md "$(SolutionDir)output\plugins\$(TargetName)"
402+
<PostBuildEvent>IF NOT EXIST "$(SolutionDir)output\plugins\$(TargetName)" (
403+
md "$(SolutionDir)output\plugins\$(TargetName)"
404+
)
403405

404406
copy "$(ProjectDir)..\NppPlugin.Host\output\NppPlugin.x64.dll" "$(SolutionDir)output\plugins\$(TargetName).x64.dll"
405407
copy "$(ProjectDir)..\NppPlugin.Host\output\NppPlugin.x86.dll" "$(SolutionDir)output\plugins\$(TargetName).x86.dll"

src/CSScriptNpp/CSScriptNpp/CSScriptHelper.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,21 @@ public static void ShowIntegrationWarning()
360360
public static string InstallCssDotnetCmd => $"dotnet tool {(IsCSScriptInstalled ? "update" : "install")} --global cs-script.cli";
361361

362362
public static string InstallCsSyntaxerDotnetCmd => $"dotnet tool {(IsCSSyntaxerInstalled ? "update" : "install")} --global cs-syntaxer";
363+
public static string InstallCsSyntaxerDotnetCmdFull => $@"echo off
364+
365+
echo Stopping any running syntaxer instance...
366+
syntaxer -list kill *
367+
368+
echo Installing/updating...
369+
{InstallCsSyntaxerDotnetCmd}";
370+
371+
public static string InstallCssDotnetCmdFull => $@"echo off
372+
373+
echo Stopping any running CS-Script instance...
374+
css -list kill *
375+
376+
echo Installing/updating...
377+
{InstallCssDotnetCmd}";
363378

364379
public static bool IsChocoInstalled
365380
{

src/CSScriptNpp/Dialogs/ConfigForm.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Threading;
88
using System.Threading.Tasks;
99
using System.Windows.Forms;
10+
using CSScriptIntellisense;
1011
using CSScriptIntellisense.Interop;
1112
using CSScriptNpp.Dialogs;
1213

@@ -172,17 +173,17 @@ static void InstallDependencies(string command)
172173
// batchFileContent.Add("powershell iex((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))");
173174
// }
174175

175-
batchFileContent.Add($"powershell {command}");
176+
batchFileContent.AddRange(command.GetLines());
176177

177178
if (batchFileContent.Count == 1)
178179
InstallDependenciesDialog.Execute(batchFileContent.First());
179180
else
180-
InstallDependenciesDialog.ShowDialog(string.Join(Environment.NewLine, batchFileContent));
181+
InstallDependenciesDialog.ShowDialog(command);
181182
}
182183

183-
public void deployCSScript_Click(object sender, EventArgs e) => InstallDependencies(CSScriptHelper.InstallCssDotnetCmd);
184+
public void deployCSScript_Click(object sender, EventArgs e) => InstallDependencies(CSScriptHelper.InstallCssDotnetCmdFull);
184185

185-
void deploySyntaxer_Click(object sender, EventArgs e) => InstallDependencies(CSScriptHelper.InstallCsSyntaxerDotnetCmd);
186+
void deploySyntaxer_Click(object sender, EventArgs e) => InstallDependencies(CSScriptHelper.InstallCsSyntaxerDotnetCmdFull);
186187

187188
void autodetectCSS_Click(object sender, EventArgs e)
188189
{

src/CSScriptNpp/Dialogs/InstallDependenciesDialog.Designer.cs

Lines changed: 23 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/CSScriptNpp/Dialogs/InstallDependenciesDialog.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ internal static void Execute(string command)
3737
{
3838
File.WriteAllText(batchFile, command + Environment.NewLine + "pause");
3939

40-
MessageBox.Show("You are about to install CS-Script component(s).\n" +
41-
"The change will take full effect after Notepad++ is restarted", "CS-Script");
42-
4340
var p = new Process();
4441
p.StartInfo.FileName = batchFile;
45-
p.StartInfo.Verb = "runas";
42+
p.StartInfo.Verb = command.Contains("choco ") ? "runas" : "";
4643
p.Start();
4744
}
4845
catch

0 commit comments

Comments
 (0)