diff --git a/Shell/PublishVS.psm1 b/Shell/PublishVS.psm1
index ab70c66ee..2c9a46ee6 100644
--- a/Shell/PublishVS.psm1
+++ b/Shell/PublishVS.psm1
@@ -7,6 +7,14 @@ function CSH-PublishVS {
$repositoryRoot = Join-Path $PSScriptRoot ".."
$vsRoot = Join-Path $repositoryRoot "/Src/CSharpier.VisualStudio"
+ $msbuild = "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\msbuild.exe"
+
+ & $msbuild $vsRoot\CSharpier.VisualStudio.sln -p:Configuration=Release
+
+ if ($LASTEXITCODE -ne 0) {
+ return
+ }
+
$vsixPath = "C:\Program Files\Microsoft Visual Studio\2022\Professional\VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe"
& $vsixPath publish `
diff --git a/Src/CSharpier.VisualStudio/CONTRIBUTING.md b/Src/CSharpier.VisualStudio/CONTRIBUTING.md
index 6c5db34fd..13cc60927 100644
--- a/Src/CSharpier.VisualStudio/CONTRIBUTING.md
+++ b/Src/CSharpier.VisualStudio/CONTRIBUTING.md
@@ -7,7 +7,6 @@ Uninstalling both csharpier and csharpier 2019 from the test instance and restar
Publishing
- Update version in BOTH files at CSharpier.VisualStudio[2019]/source.extension.vsixmanifest
- Update ChangeLog.md
-- build solution in release (can this happen via command line?)
- use cli
- CSH-PublishVS [AccessToken]
- old way
diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudio/CSharpier.VisualStudio.csproj b/Src/CSharpier.VisualStudio/CSharpier.VisualStudio/CSharpier.VisualStudio.csproj
index af06b7964..f74b2c562 100644
--- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudio/CSharpier.VisualStudio.csproj
+++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudio/CSharpier.VisualStudio.csproj
@@ -76,8 +76,8 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudio/source.extension.vsixmanifest b/Src/CSharpier.VisualStudio/CSharpier.VisualStudio/source.extension.vsixmanifest
index a0005a64e..2dcc6c075 100644
--- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudio/source.extension.vsixmanifest
+++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudio/source.extension.vsixmanifest
@@ -1,7 +1,7 @@
-
+
CSharpier
CSharpier is an opinionated code formatter for c#. It uses Roslyn to parse your code and re-prints it using its own rules.
https://github.com/belav/csharpier
diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/CSharpier.VisualStudio2019.csproj b/Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/CSharpier.VisualStudio2019.csproj
index ff49257c7..4aebd822b 100644
--- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/CSharpier.VisualStudio2019.csproj
+++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/CSharpier.VisualStudio2019.csproj
@@ -38,6 +38,7 @@
TRACE;DEBUG;DEV16
prompt
4
+ False
pdbonly
@@ -46,6 +47,7 @@
TRACE
prompt
4
+ False
@@ -76,8 +78,8 @@
-
-
+
+
diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/source.extension.vsixmanifest b/Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/source.extension.vsixmanifest
index dc6fe1508..85c27791c 100644
--- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/source.extension.vsixmanifest
+++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/source.extension.vsixmanifest
@@ -1,7 +1,7 @@
-
+
CSharpier 2019
CSharpier is an opinionated code formatter for c#. It uses Roslyn to parse your code and re-prints it using its own rules.
https://github.com/belav/csharpier
diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs
index 8cf32ea58..e9ae64cd4 100644
--- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs
+++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs
@@ -60,7 +60,7 @@ protected void LoadFrom(CSharpierOptions newInstance)
ThreadHelper.JoinableTaskFactory
);
- private static FileSystemWatcher _hotReloadWatcher;
+ private static FileSystemWatcher? hotReloadWatcher;
public static CSharpierOptions Instance
{
@@ -83,7 +83,7 @@ private static async Task CreateAsync()
public void Load()
{
- ThreadHelper.JoinableTaskFactory.Run(LoadAsync);
+ ThreadHelper.JoinableTaskFactory.Run(this.LoadAsync);
}
private async Task LoadAsync()
@@ -140,7 +140,7 @@ await LoadOptionsFromFile(
public void Save()
{
- ThreadHelper.JoinableTaskFactory.Run(SaveAsync);
+ ThreadHelper.JoinableTaskFactory.Run(this.SaveAsync);
}
public async Task SaveAsync()
@@ -204,6 +204,7 @@ await SaveOptions(
private static async Task GetSolutionOptionsFileNameAsync()
{
+ await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
#pragma warning disable VSSDK006
var solution =
await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SVsSolution))
@@ -212,16 +213,20 @@ await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SVsSolution))
solution!.GetSolutionInfo(out _, out _, out var userOptsFile);
return userOptsFile != null
- ? Path.Combine(Path.GetDirectoryName(userOptsFile), "csharpier.json")
+ ? Path.Combine(Path.GetDirectoryName(userOptsFile)!, "csharpier.json")
: null;
}
private static async Task InitializeHotReloadWatcherAsync()
{
- string filePath = await GetSolutionOptionsFileNameAsync();
+ var filePath = await GetSolutionOptionsFileNameAsync();
+ if (filePath is null)
+ {
+ return;
+ }
- _hotReloadWatcher = new FileSystemWatcher(
- Path.GetDirectoryName(filePath),
+ hotReloadWatcher = new FileSystemWatcher(
+ Path.GetDirectoryName(filePath)!,
Path.GetFileName(filePath)
);
@@ -236,11 +241,11 @@ static void OnFileChanged(object sender, FileSystemEventArgs e)
#pragma warning restore
}
- _hotReloadWatcher.Changed += OnFileChanged;
- _hotReloadWatcher.Created += OnFileChanged;
- _hotReloadWatcher.Renamed += OnFileChanged;
+ hotReloadWatcher.Changed += OnFileChanged;
+ hotReloadWatcher.Created += OnFileChanged;
+ hotReloadWatcher.Renamed += OnFileChanged;
- _hotReloadWatcher.EnableRaisingEvents = true;
+ hotReloadWatcher.EnableRaisingEvents = true;
}
private class OptionsDto
diff --git a/Src/CSharpier.VisualStudio/ChangeLog.md b/Src/CSharpier.VisualStudio/ChangeLog.md
index fcb651242..70c66208b 100644
--- a/Src/CSharpier.VisualStudio/ChangeLog.md
+++ b/Src/CSharpier.VisualStudio/ChangeLog.md
@@ -1,4 +1,7 @@
-## [1.9.0]
+## [1.9.1]
+- Fix bug if you open CSharpier options page without a solution loaded in VisualStudio
+
+## [1.9.0]
- Configuration will hot reload: changes to `.vs/$(SolutionName)/v17/csharpier.json` will trigger a reload of the configuration in an opened Visual Studio instance.
## [1.8.0]