diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 53f29f6464..a76dbbea85 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -119,6 +119,48 @@ jobs:
name: nuget_packages
path: src/${{ matrix.component.name }}.CodeFixes/bin/Release/*.*nupkg
+ build_refactorings:
+ if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
+ needs: pre_build
+ runs-on: ubuntu-22.04
+ env:
+ Version: ${{ needs.pre_build.outputs.version }}
+ defaults:
+ run:
+ working-directory: src/Refactorings
+ steps:
+ - uses: actions/checkout@v3
+ - run: dotnet restore --force /p:RoslynVersion=roslyn3.8
+ - run: dotnet build --no-restore /p:RoslynatorRefactoringsNuGet=true /p:RoslynVersion=roslyn3.8
+ - run: dotnet restore --force /p:RoslynVersion=roslyn4.7
+ - run: dotnet build --no-restore /p:RoslynatorRefactoringsNuGet=true /p:RoslynVersion=roslyn4.7
+ - run: dotnet pack --no-build
+ - uses: actions/upload-artifact@v3
+ with:
+ name: nuget_packages
+ path: src/Refactorings/bin/Release/*.*nupkg
+
+ build_code_fixes:
+ if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
+ needs: pre_build
+ runs-on: ubuntu-22.04
+ env:
+ Version: ${{ needs.pre_build.outputs.version }}
+ defaults:
+ run:
+ working-directory: src/CodeFixes
+ steps:
+ - uses: actions/checkout@v3
+ - run: dotnet restore --force /p:RoslynVersion=roslyn3.8
+ - run: dotnet build --no-restore /p:RoslynatorCodeFixesNuGet=true /p:RoslynVersion=roslyn3.8
+ - run: dotnet restore --force /p:RoslynVersion=roslyn4.7
+ - run: dotnet build --no-restore /p:RoslynatorCodeFixesNuGet=true /p:RoslynVersion=roslyn4.7
+ - run: dotnet pack --no-build
+ - uses: actions/upload-artifact@v3
+ with:
+ name: nuget_packages
+ path: src/CodeFixes/bin/Release/*.*nupkg
+
build_vs_extension:
if: github.ref_type != 'tag' || startsWith(github.ref_name, 'v')
needs: pre_build
@@ -242,7 +284,7 @@ jobs:
path: src/CommandLine/bin/Release/*.*nupkg
publish_nuget_packages:
- needs: [ build_core_and_testing, build_analyzers ]
+ needs: [ build_core_and_testing, build_analyzers, build_refactorings, build_code_fixes ]
runs-on: ubuntu-22.04
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
steps:
diff --git a/ChangeLog.md b/ChangeLog.md
index dc6c547db3..0c2d5fe434 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+
+- Publish NuGet packages that provide [refactorings](https://www.nuget.org/packages/roslynator.refactorings) and [code fixes for compiler diagnostics](https://www.nuget.org/packages/roslynator.codefixes) ([PR](https://github.com/dotnet/roslynator/pull/1358))
+ - These packages are recommended to be used in an environment where Roslynator IDE extension cannot be used, e.g. VS Code + C# Dev Kit (see related [issue](https://github.com/dotnet/vscode-csharp/issues/6790))
+
### Fixed
- Fix analyzer [RCS1055](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1055) ([PR](https://github.com/dotnet/roslynator/pull/1361))
diff --git a/src/CodeFixes/CodeFixes.csproj b/src/CodeFixes/CodeFixes.csproj
index f99cb0d655..a12d091806 100644
--- a/src/CodeFixes/CodeFixes.csproj
+++ b/src/CodeFixes/CodeFixes.csproj
@@ -4,13 +4,18 @@
netstandard2.0
+
+ bin\$(RoslynVersion)\
+
+
$(RoslynatorVersion)
Roslynator.CSharp.CodeFixes
Roslynator.CSharp.CodeFixes
Roslynator.CodeFixes.nuspec
- configuration=$(Configuration)
- false
+ configuration=$(Configuration);version=$(RoslynatorPackageVersion)
+ true
+ false
diff --git a/src/CodeFixes/Roslynator.CodeFixes.nuspec b/src/CodeFixes/Roslynator.CodeFixes.nuspec
index d9bf0c4a7f..0e3dbfb468 100644
--- a/src/CodeFixes/Roslynator.CodeFixes.nuspec
+++ b/src/CodeFixes/Roslynator.CodeFixes.nuspec
@@ -9,16 +9,19 @@
https://github.com/dotnet/roslynator
icon.png
false
- A collection of code fixes for C# compiler diagnostics (CS....), powered by Roslyn.
- A collection of code fixes for C# compiler diagnostics (CS....), powered by Roslyn.
- Copyright (c) 2016-2023 Josef Pihrt
- Roslyn Analyzer Refactoring Productivity CodeAnalysis C# CSharp
+ A collection of code fixes for C# compiler diagnostics, powered by Roslyn.
+ A collection of code fixes for C# compiler diagnostics, powered by Roslyn.
+ Copyright (c) 2016-2024 Josef Pihrt
+ Roslyn Refactoring Productivity CodeAnalysis C# CSharp
true
+ docs\README.md
-
+
+
+
\ No newline at end of file
diff --git a/src/CodeFixes/docs/NuGetReadme.md b/src/CodeFixes/docs/NuGetReadme.md
new file mode 100644
index 0000000000..298a1847f4
--- /dev/null
+++ b/src/CodeFixes/docs/NuGetReadme.md
@@ -0,0 +1,33 @@
+# Roslynator.CodeFixes
+
+A collection [code fixes](https://josefpihrt.github.io/docs/roslynator/fixes) for C# compiler diagnostics, powered by [Roslyn](https://github.com/dotnet/roslyn).
+
+This package is recommended to be used in an enviroment where Roslynator IDE extensions cannot be used, e.g. VS Code + C# Dev Kit.
+Otherwise, do not use this package and use IDE extension which has the same functionality.
+
+## Requirements
+
+* Visual Studio 2022
+* VS Code with [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) extension 1.21.13 or higher
+* Roslyn 3.8.0 or higher (when used directly, not as a part of IDE)
+
+## Usage
+
+* Add package to your project:
+ ```shell
+ dotnet add package roslynator.codefixes
+ ```
+
+* Use EditorConfig to [configure](https://josefpihrt.github.io/docs/roslynator/configuration) analyzers.
+
+## Feedback
+
+* File an issue on [GitHub](https://github.com/dotnet/roslynator/issues/new)
+* Follow on [Twitter](https://twitter.com/roslynator)
+
+## Related Products
+
+* [Roslynator for Visual Studio 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022)
+* [Roslynator for VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator)
+* [Roslynator Command-line Tool](https://www.nuget.org/packages/Roslynator.DotNet.Cli)
+* [Roslynator Testing Framework](https://www.nuget.org/packages/Roslynator.Testing.CSharp.Xunit)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 8d6ccc3c1b..efb8c06f49 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -62,6 +62,14 @@
Roslynator_Formatting_Analyzers_
+
+ Roslynator_Refactorings_
+
+
+
+ Roslynator_CodeFixes_
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Refactorings/Refactorings.csproj b/src/Refactorings/Refactorings.csproj
index 71c67f7388..f2191372ac 100644
--- a/src/Refactorings/Refactorings.csproj
+++ b/src/Refactorings/Refactorings.csproj
@@ -4,17 +4,24 @@
netstandard2.0
+
+ bin\$(RoslynVersion)\
+
+
$(RoslynatorVersion)
Roslynator.CSharp.Refactorings
Roslynator.CSharp.Refactorings
+ Roslynator.Refactorings.nuspec
+ configuration=$(Configuration);version=$(RoslynatorPackageVersion)
+ true
+ false
-
- false
-
-
-
+
+
+
+
@@ -24,8 +31,6 @@
-
-
diff --git a/src/Refactorings/Roslynator.Refactorings.nuspec b/src/Refactorings/Roslynator.Refactorings.nuspec
new file mode 100644
index 0000000000..7b546dbced
--- /dev/null
+++ b/src/Refactorings/Roslynator.Refactorings.nuspec
@@ -0,0 +1,27 @@
+
+
+
+ Roslynator.Refactorings
+ $version$
+ Josef Pihrt
+ Josef Pihrt
+ Apache-2.0
+ https://github.com/dotnet/roslynator
+ icon.png
+ false
+ A collection of 200+ refactorings for C#, powered by Roslyn.
+ A collection of 200+ refactorings for C#, powered by Roslyn.
+ Copyright (c) 2016-2024 Josef Pihrt
+ Roslyn Refactoring Productivity CodeAnalysis C# CSharp
+ true
+
+ docs\README.md
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Refactorings/docs/NuGetReadme.md b/src/Refactorings/docs/NuGetReadme.md
new file mode 100644
index 0000000000..8b4ed9f403
--- /dev/null
+++ b/src/Refactorings/docs/NuGetReadme.md
@@ -0,0 +1,33 @@
+# Roslynator.Refactorings
+
+A collection of 200+ [refactorings](https://josefpihrt.github.io/docs/roslynator/refactorings) for C#, powered by [Roslyn](https://github.com/dotnet/roslyn).
+
+This package is recommended to be used in an enviroment where Roslynator IDE extensions cannot be used, e.g. VS Code + C# Dev Kit.
+Otherwise, do not use this package and use IDE extension which has the same functionality.
+
+## Requirements
+
+* Visual Studio 2022
+* VS Code with [C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) extension 1.21.13 or higher
+* Roslyn 3.8.0 or higher (when used directly, not as a part of IDE)
+
+## Usage
+
+* Add package to your project:
+ ```shell
+ dotnet add package roslynator.refactorings
+ ```
+
+* Use EditorConfig to [configure](https://josefpihrt.github.io/docs/roslynator/configuration) analyzers.
+
+## Feedback
+
+* File an issue on [GitHub](https://github.com/dotnet/roslynator/issues/new)
+* Follow on [Twitter](https://twitter.com/roslynator)
+
+## Related Products
+
+* [Roslynator for Visual Studio 2022](https://marketplace.visualstudio.com/items?itemName=josefpihrt.Roslynator2022)
+* [Roslynator for VS Code](https://marketplace.visualstudio.com/items?itemName=josefpihrt-vscode.roslynator)
+* [Roslynator Command-line Tool](https://www.nuget.org/packages/Roslynator.DotNet.Cli)
+* [Roslynator Testing Framework](https://www.nuget.org/packages/Roslynator.Testing.CSharp.Xunit)
diff --git a/src/Refactorings/tools/install.ps1 b/src/Refactorings/tools/install.ps1
new file mode 100644
index 0000000000..8178834faf
--- /dev/null
+++ b/src/Refactorings/tools/install.ps1
@@ -0,0 +1,49 @@
+param($installPath, $toolsPath, $package, $project)
+
+$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve
+
+foreach($analyzersPath in $analyzersPaths)
+{
+ # Install the language agnostic analyzers.
+ if (Test-Path $analyzersPath)
+ {
+ foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll)
+ {
+ if($project.Object.AnalyzerReferences)
+ {
+ $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
+ }
+ }
+ }
+}
+
+# $project.Type gives the language name like (C# or VB.NET)
+$languageFolder = ""
+if($project.Type -eq "C#")
+{
+ $languageFolder = "cs"
+}
+if($project.Type -eq "VB.NET")
+{
+ $languageFolder = "vb"
+}
+if($languageFolder -eq "")
+{
+ return
+}
+
+foreach($analyzersPath in $analyzersPaths)
+{
+ # Install language specific analyzers.
+ $languageAnalyzersPath = join-path $analyzersPath $languageFolder
+ if (Test-Path $languageAnalyzersPath)
+ {
+ foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll)
+ {
+ if($project.Object.AnalyzerReferences)
+ {
+ $project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Refactorings/tools/uninstall.ps1 b/src/Refactorings/tools/uninstall.ps1
new file mode 100644
index 0000000000..9130bcb508
--- /dev/null
+++ b/src/Refactorings/tools/uninstall.ps1
@@ -0,0 +1,56 @@
+param($installPath, $toolsPath, $package, $project)
+
+$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve
+
+foreach($analyzersPath in $analyzersPaths)
+{
+ # Uninstall the language agnostic analyzers.
+ if (Test-Path $analyzersPath)
+ {
+ foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll)
+ {
+ if($project.Object.AnalyzerReferences)
+ {
+ $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
+ }
+ }
+ }
+}
+
+# $project.Type gives the language name like (C# or VB.NET)
+$languageFolder = ""
+if($project.Type -eq "C#")
+{
+ $languageFolder = "cs"
+}
+if($project.Type -eq "VB.NET")
+{
+ $languageFolder = "vb"
+}
+if($languageFolder -eq "")
+{
+ return
+}
+
+foreach($analyzersPath in $analyzersPaths)
+{
+ # Uninstall language specific analyzers.
+ $languageAnalyzersPath = join-path $analyzersPath $languageFolder
+ if (Test-Path $languageAnalyzersPath)
+ {
+ foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll)
+ {
+ if($project.Object.AnalyzerReferences)
+ {
+ try
+ {
+ $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
+ }
+ catch
+ {
+
+ }
+ }
+ }
+ }
+}
\ No newline at end of file