From 1c76620a73386fc77bbfe85d5f19a00e687fee00 Mon Sep 17 00:00:00 2001 From: Jesper Lundberg Date: Fri, 15 Nov 2024 17:59:58 +0100 Subject: [PATCH 1/9] Update Editors.md with conform.nvim suggestion for Neovim (#1379) Added info on Neovim to use Conform. --- docs/Editors.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/Editors.md b/docs/Editors.md index 71f0b4ed2..cc9dc1305 100644 --- a/docs/Editors.md +++ b/docs/Editors.md @@ -22,6 +22,8 @@ Use the [official plugin](https://plugins.jetbrains.com/plugin/18243-csharpier) It can be installed via the Plugins dialog. ### Neovim +Use [conform.nvim](https://github.com/stevearc/conform.nvim) +or Use [neoformat](https://github.com/sbdchd/neoformat) ### Emacs From 4dfa2430ab98beaadb587c209ac7619ae5adea83 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sun, 17 Nov 2024 10:44:03 -0600 Subject: [PATCH 2/9] Ensure we are ready for the next major version. (#1380) --- Src/CSharpier.Cli/CSharpier.Cli.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/CSharpier.Cli/CSharpier.Cli.csproj b/Src/CSharpier.Cli/CSharpier.Cli.csproj index 3992eb21f..7ea0b76be 100644 --- a/Src/CSharpier.Cli/CSharpier.Cli.csproj +++ b/Src/CSharpier.Cli/CSharpier.Cli.csproj @@ -8,6 +8,7 @@ true csharpier ../../Nuget/csharpier.snk + Major True 002400000480000094000000060200000024000052534131000400000100010049d266ea1aeae09c0abfce28b8728314d4e4807126ee8bc56155a7ddc765997ed3522908b469ae133fc49ef0bfa957df36082c1c2e0ec8cdc05a4ca4dbd4e1bea6c17fc1008555e15af13a8fc871a04ffc38f5e60e6203bfaf01d16a2a283b90572ade79135801c1675bf38b7a5a60ec8353069796eb53a26ffdddc9ee1273be From 0425539f1f2a5de0915a0f4abe790896354fd47c Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sun, 17 Nov 2024 11:03:04 -0600 Subject: [PATCH 3/9] Releasing 0.30.0 (#1381) --- CHANGELOG.md | 113 ++++++++++++++++++++- Nuget/Build.props | 2 +- Src/Website/docs/Editors.md | 2 + Src/Website/docs/EditorsTroubleshooting.md | 4 +- Src/Website/docs/MsBuild.md | 6 +- 5 files changed, 120 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8a4d5130..444f66829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,114 @@ -# 0.29.2 +# 0.30.0 +## Breaking Changes +The CSharpier dotnet tool no longer supports net6 & net7. +## What's Changed +### Support C# 13 & dotnet 9. [#1318](https://github.com/belav/csharpier/issues/1318) +CSharpier now supports dotnet 9 along with formatting all C# 13 language features. +### Inconsistent Formatting for new() Operator Compared to Explicit Object Constructors [#1364](https://github.com/belav/csharpier/issues/1364) +Implicit and explicit object initialization with constructors was not formatted consistently +```c# +// input & expected output +SomeObject someObject = new( + someLongParameter___________________, + someLongParameter___________________ +) +{ + Property = longValue_______________________________________________________________________, +}; + +SomeObject someObject = new SomeObject( + someLongParameter___________________, + someLongParameter___________________ +) +{ + Property = longValue_______________________________________________________________________, +}; + +// 0.29.2 +SomeObject someObject = + new(someLongParameter___________________, someLongParameter___________________) + { + Property = longValue_______________________________________________________________________, + }; + +SomeObject someObject = new SomeObject( + someLongParameter___________________, + someLongParameter___________________ +) +{ + Property = longValue_______________________________________________________________________, +}; + +``` +### Adds additional space before each member access in verbatim interpolated multiline string [#1358](https://github.com/belav/csharpier/issues/1358) +When an interpolated verbatim string contained line breaks, the code within the interpolations would contain extra spaces. +```c# +// input & expected output +var someStringWithLineBreakAndLongValue = + $@" +{someValue.GetValue().Name} someLongText________________________________________________________________"; + +// 0.29.2 +var someStringWithLineBreakAndLongValue = + $@" + {someValue .GetValue() .Name} someLongText________________________________________________________________"; +``` + +### Inserting trailing comma with trailing comment causes problems. [#1354](https://github.com/belav/csharpier/issues/1354) +CSharpier would insert a trailing comma after a trailing comment and format the end result poorly. +```c# +// input +var someObject = new SomeObject() +{ + Property1 = 1, + Property2 = 2 // Trailing Comment +}; + +// 0.29.2 +var someObject = new SomeObject() +{ + Property1 = 1, + Property2 = + 2 // Trailing Comment + , +}; + +// 0.30.0 +var someObject = new SomeObject() +{ + Property1 = 1, + Property2 = 2, // Trailing Comment +}; +``` + +### Double line break before collection expression in field [#1351](https://github.com/belav/csharpier/issues/1351) +CSharpier was inserting an extra line break on a long field name followed by a collection expression to initialize it. +```c# +// input & expected output +class ClassName +{ + public SomeType[] LongName____________________________________________________________________________ = + [ + someLongValue___________________________________________________, + someLongValue___________________________________________________, + ]; +} + +// 0.29.2 +class ClassName +{ + public SomeType[] LongName____________________________________________________________________________ = + + [ + someLongValue___________________________________________________, + someLongValue___________________________________________________, + ]; +} + +``` + +**Full Changelog**: https://github.com/belav/csharpier/compare/0.29.2...0.30.0 +# 0.29.2 ## What's Changed ### Comments don't follow tabs indent style [#1343](https://github.com/belav/csharpier/issues/1343) Prior to `0.29.2` CSharpier was converting any tabs within the block of a multiline comment to spaces. @@ -2653,3 +2763,4 @@ Thanks go to @pingzing + diff --git a/Nuget/Build.props b/Nuget/Build.props index ad5774fd5..44e1798fb 100644 --- a/Nuget/Build.props +++ b/Nuget/Build.props @@ -1,6 +1,6 @@ - 0.29.2 + 0.30.0 MIT https://github.com/belav/csharpier git diff --git a/Src/Website/docs/Editors.md b/Src/Website/docs/Editors.md index 71f0b4ed2..cc9dc1305 100644 --- a/Src/Website/docs/Editors.md +++ b/Src/Website/docs/Editors.md @@ -22,6 +22,8 @@ Use the [official plugin](https://plugins.jetbrains.com/plugin/18243-csharpier) It can be installed via the Plugins dialog. ### Neovim +Use [conform.nvim](https://github.com/stevearc/conform.nvim) +or Use [neoformat](https://github.com/sbdchd/neoformat) ### Emacs diff --git a/Src/Website/docs/EditorsTroubleshooting.md b/Src/Website/docs/EditorsTroubleshooting.md index 86e1e4b30..68f3703c5 100644 --- a/Src/Website/docs/EditorsTroubleshooting.md +++ b/Src/Website/docs/EditorsTroubleshooting.md @@ -34,7 +34,7 @@ When the extension is unable to format files, it is generally a problem with bei - Change the dropdown to `CSharpier` ### Rider -- Execute the action `Show Log in Explorer +- Execute the action `Show Log in Explorer` - Look for lines that contain `#c.i.c.CSharpierLogger` ## Troubleshooting Steps @@ -46,7 +46,7 @@ The following can help track down issues with the extension being unable to inst `C:\Users\[UserName]\AppData\Local\CSharpier\[CSharpierVersion]` or
`$HOME/.cache/csharpier/[CSharpierVersion]` 3. Assuming the directory above exists, attempt to run the following in that directory
- `dotnet-csharpier --version` + `dotnet csharpier --version` 4. If the installation appears to be corrupt, delete the directory and install CSharpier there yourself
`dotnet tool install csharpier --version [CSharpierVersion] --tool-path [PathFromStep2]` 5. Repeat step 3 to validate the install diff --git a/Src/Website/docs/MsBuild.md b/Src/Website/docs/MsBuild.md index 700f5f9e3..75c508ab8 100644 --- a/Src/Website/docs/MsBuild.md +++ b/Src/Website/docs/MsBuild.md @@ -51,10 +51,10 @@ Valid options are: - Debug ### Target Frameworks -CSharpier.MSBuild will be run with net6.0, net7.0 or net8.0 if the project targets one of the three frameworks. In cases where the project targets something else (net48, netstandard2.0) `CSharpier_FrameworkVersion` will default to net7.0 -This can be controlled with the following property. This property is required if the csproj is targeting < net6.0 (netstandard2.0, net48, etc) and net7.0 is not installed. +CSharpier.MSBuild will be run with net8.0 or net9.0 if the project targets one of the three frameworks. In cases where the project targets something else (net48, netstandard2.0) `CSharpier_FrameworkVersion` will default to net8.0 +This can be controlled with the following property. This property is required if the csproj is targeting < net8.0 (netstandard2.0, net48, etc) and net8.0 is not installed. ```xml - net6.0 + net8.0 ``` From 6375faba9185f3c7a2d01eb07ba2b7082721db53 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sun, 17 Nov 2024 19:46:12 -0600 Subject: [PATCH 4/9] revert tool command, this was supposed to be in 1.0.0 only (#1383) closes #1382 --- Src/CSharpier.Cli/CSharpier.Cli.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Src/CSharpier.Cli/CSharpier.Cli.csproj b/Src/CSharpier.Cli/CSharpier.Cli.csproj index 7ea0b76be..8fffade6d 100644 --- a/Src/CSharpier.Cli/CSharpier.Cli.csproj +++ b/Src/CSharpier.Cli/CSharpier.Cli.csproj @@ -6,7 +6,6 @@ dotnet-csharpier net8.0;net9.0 true - csharpier ../../Nuget/csharpier.snk Major True From fedc791cc22961a913669283ccd6518640499a64 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sun, 17 Nov 2024 19:49:47 -0600 Subject: [PATCH 5/9] Releasing 0.30.1 (#1384) --- CHANGELOG.md | 6 +++++- Nuget/Build.props | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 444f66829..7ef0f0c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -# 0.30.0 +# 0.30.1 +## What's Changed +Revert tool command back to `dotnet-csharpier`, it was supposed to be changed to `csharpier` for 1.0.0 + +# 0.30.0 ## Breaking Changes The CSharpier dotnet tool no longer supports net6 & net7. ## What's Changed diff --git a/Nuget/Build.props b/Nuget/Build.props index 44e1798fb..c75d7165f 100644 --- a/Nuget/Build.props +++ b/Nuget/Build.props @@ -1,6 +1,6 @@ - 0.30.0 + 0.30.1 MIT https://github.com/belav/csharpier git From 4dd71fab419b24144ad2db85addc1156ea47c481 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Mon, 18 Nov 2024 09:09:25 -0600 Subject: [PATCH 6/9] formatting with 0.30.1 (#1386) --- .config/dotnet-tools.json | 2 +- .../EditorConfig/ConfigFileParser.cs | 19 ++-- Src/CSharpier.Cli/EditorConfig/Globber.cs | 15 ++-- Src/CSharpier.FakeGenerators/Ignored.cs | 36 ++++---- Src/CSharpier.Tests/MissingTypeChecker.cs | 89 +++++++++---------- .../CSharpierOptions.cs | 6 +- Src/CSharpier/DocTypes/Doc.cs | 6 +- .../Formatters/CSharp/PreprocessorSymbols.cs | 6 +- 8 files changed, 90 insertions(+), 89 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b439c8ade..a0f59deb2 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "csharpier": { - "version": "0.29.2", + "version": "0.30.1", "commands": [ "dotnet-csharpier" ] diff --git a/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs b/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs index 8f1a0cd4b..65066c9c4 100644 --- a/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs +++ b/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs @@ -12,16 +12,15 @@ internal static class ConfigFileParser // "Comment: starts with a ; or a #." private static readonly Regex CommentRegex = new("^[;#].*$"); - private static readonly IniParserConfiguration Configuration = - new() - { - CommentRegex = CommentRegex, - AllowDuplicateKeys = true, - AllowDuplicateSections = true, - OverrideDuplicateKeys = true, - SkipInvalidLines = true, - ThrowExceptionsOnError = false, - }; + private static readonly IniParserConfiguration Configuration = new() + { + CommentRegex = CommentRegex, + AllowDuplicateKeys = true, + AllowDuplicateSections = true, + OverrideDuplicateKeys = true, + SkipInvalidLines = true, + ThrowExceptionsOnError = false, + }; public static ConfigFile Parse(string filePath, IFileSystem fileSystem) { diff --git a/Src/CSharpier.Cli/EditorConfig/Globber.cs b/Src/CSharpier.Cli/EditorConfig/Globber.cs index 9d9a46a59..d8fe6709b 100644 --- a/Src/CSharpier.Cli/EditorConfig/Globber.cs +++ b/Src/CSharpier.Cli/EditorConfig/Globber.cs @@ -2,14 +2,13 @@ namespace CSharpier.Cli.EditorConfig; internal static class Globber { - private static readonly GlobMatcherOptions globOptions = - new() - { - MatchBase = true, - Dot = true, - AllowWindowsPaths = true, - AllowSingleBraceSets = true, - }; + private static readonly GlobMatcherOptions globOptions = new() + { + MatchBase = true, + Dot = true, + AllowWindowsPaths = true, + AllowSingleBraceSets = true, + }; public static GlobMatcher Create(string files, string directory) { diff --git a/Src/CSharpier.FakeGenerators/Ignored.cs b/Src/CSharpier.FakeGenerators/Ignored.cs index 64749e215..05b0c4051 100644 --- a/Src/CSharpier.FakeGenerators/Ignored.cs +++ b/Src/CSharpier.FakeGenerators/Ignored.cs @@ -23,24 +23,22 @@ public static class Ignored public static readonly Type[] Types = { typeof(TextSpan), typeof(SyntaxTree) }; - public static readonly Dictionary PropertiesByType = - new() - { - { typeof(PropertyDeclarationSyntax), new[] { "semicolon" } }, - { typeof(IndexerDeclarationSyntax), new[] { "semicolon" } }, - { typeof(SyntaxTrivia), new[] { "token" } }, - { typeof(SyntaxToken), new[] { "value", "valueText" } }, - { typeof(ParameterSyntax), new[] { "exclamationExclamationToken" } }, - }; + public static readonly Dictionary PropertiesByType = new() + { + { typeof(PropertyDeclarationSyntax), new[] { "semicolon" } }, + { typeof(IndexerDeclarationSyntax), new[] { "semicolon" } }, + { typeof(SyntaxTrivia), new[] { "token" } }, + { typeof(SyntaxToken), new[] { "value", "valueText" } }, + { typeof(ParameterSyntax), new[] { "exclamationExclamationToken" } }, + }; - public static readonly HashSet UnsupportedNodes = - new() - { - // if new versions of c# add node types, we need to ignore them in the generators - // until codeAnalysis + sdks are updated - // global.json doesn't seem to always be respected for builds (namely VS but rider started having the same problem) - // which causes the generators to generate code for the new node types - // but then the build fails because those types don't exist in the packages the actual project references - // "ListPatternSyntax", "SlicePatternSyntax" - }; + public static readonly HashSet UnsupportedNodes = new() + { + // if new versions of c# add node types, we need to ignore them in the generators + // until codeAnalysis + sdks are updated + // global.json doesn't seem to always be respected for builds (namely VS but rider started having the same problem) + // which causes the generators to generate code for the new node types + // but then the build fails because those types don't exist in the packages the actual project references + // "ListPatternSyntax", "SlicePatternSyntax" + }; } diff --git a/Src/CSharpier.Tests/MissingTypeChecker.cs b/Src/CSharpier.Tests/MissingTypeChecker.cs index 6f1f78495..77c211b30 100644 --- a/Src/CSharpier.Tests/MissingTypeChecker.cs +++ b/Src/CSharpier.Tests/MissingTypeChecker.cs @@ -70,49 +70,48 @@ public void Ensure_There_Are_No_Missing_Types() missingTypes.Should().BeEmpty(); } - private readonly HashSet ignored = - new() - { - "AccessorDeclarationSyntax", - "AccessorListSyntax", - "AttributeArgumentListSyntax", - "AttributeArgumentSyntax", - "AttributeSyntax", - "AttributeTargetSpecifierSyntax", - "BaseListSyntax", - "CatchDeclarationSyntax", - "CatchFilterClauseSyntax", - "ConstructorInitializerSyntax", - "ConversionOperatorMemberCrefSyntax", - "CrefBracketedParameterListSyntax", - "CrefParameterListSyntax", - "CrefParameterSyntax", - "ExplicitInterfaceSpecifierSyntax", - "FunctionPointerCallingConventionSyntax", - "FunctionPointerParameterListSyntax", - "FunctionPointerParameterSyntax", - "FunctionPointerUnmanagedCallingConventionListSyntax", - "FunctionPointerUnmanagedCallingConventionSyntax", - "IndexerMemberCrefSyntax", - "InterpolationAlignmentClauseSyntax", - "InterpolationFormatClauseSyntax", - "JoinIntoClauseSyntax", - "LineDirectivePositionSyntax", - "NameMemberCrefSyntax", - "OperatorMemberCrefSyntax", - "OrderingSyntax", - "PositionalPatternClauseSyntax", - "PropertyPatternClauseSyntax", - "QualifiedCrefSyntax", - "SubpatternSyntax", - "SwitchExpressionArmSyntax", - "TypeCrefSyntax", - "XmlCrefAttributeSyntax", - "XmlElementEndTagSyntax", - "XmlElementStartTagSyntax", - "XmlNameAttributeSyntax", - "XmlNameSyntax", - "XmlPrefixSyntax", - "XmlTextAttributeSyntax", - }; + private readonly HashSet ignored = new() + { + "AccessorDeclarationSyntax", + "AccessorListSyntax", + "AttributeArgumentListSyntax", + "AttributeArgumentSyntax", + "AttributeSyntax", + "AttributeTargetSpecifierSyntax", + "BaseListSyntax", + "CatchDeclarationSyntax", + "CatchFilterClauseSyntax", + "ConstructorInitializerSyntax", + "ConversionOperatorMemberCrefSyntax", + "CrefBracketedParameterListSyntax", + "CrefParameterListSyntax", + "CrefParameterSyntax", + "ExplicitInterfaceSpecifierSyntax", + "FunctionPointerCallingConventionSyntax", + "FunctionPointerParameterListSyntax", + "FunctionPointerParameterSyntax", + "FunctionPointerUnmanagedCallingConventionListSyntax", + "FunctionPointerUnmanagedCallingConventionSyntax", + "IndexerMemberCrefSyntax", + "InterpolationAlignmentClauseSyntax", + "InterpolationFormatClauseSyntax", + "JoinIntoClauseSyntax", + "LineDirectivePositionSyntax", + "NameMemberCrefSyntax", + "OperatorMemberCrefSyntax", + "OrderingSyntax", + "PositionalPatternClauseSyntax", + "PropertyPatternClauseSyntax", + "QualifiedCrefSyntax", + "SubpatternSyntax", + "SwitchExpressionArmSyntax", + "TypeCrefSyntax", + "XmlCrefAttributeSyntax", + "XmlElementEndTagSyntax", + "XmlElementStartTagSyntax", + "XmlNameAttributeSyntax", + "XmlNameSyntax", + "XmlPrefixSyntax", + "XmlTextAttributeSyntax", + }; } diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs index 8e7e65d36..8cf32ea58 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs @@ -55,8 +55,10 @@ protected void LoadFrom(CSharpierOptions newInstance) this.DisableCSharpierServer = newInstance.DisableCSharpierServer; } - private static readonly AsyncLazy liveModel = - new(CreateAsync, ThreadHelper.JoinableTaskFactory); + private static readonly AsyncLazy liveModel = new( + CreateAsync, + ThreadHelper.JoinableTaskFactory + ); private static FileSystemWatcher _hotReloadWatcher; diff --git a/Src/CSharpier/DocTypes/Doc.cs b/Src/CSharpier/DocTypes/Doc.cs index 10edb115b..22f58a7e4 100644 --- a/Src/CSharpier/DocTypes/Doc.cs +++ b/Src/CSharpier/DocTypes/Doc.cs @@ -29,8 +29,10 @@ public static implicit operator Doc(string value) public static readonly HardLine HardLineIfNoPreviousLine = new(true); - public static readonly HardLine HardLineIfNoPreviousLineSkipBreakIfFirstInGroup = - new(true, true); + public static readonly HardLine HardLineIfNoPreviousLineSkipBreakIfFirstInGroup = new( + true, + true + ); public static readonly LiteralLine LiteralLine = new(); diff --git a/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs b/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs index 3b2ed0ff4..834b4f498 100644 --- a/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs +++ b/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs @@ -4,8 +4,10 @@ internal class PreprocessorSymbols : CSharpSyntaxWalker { private readonly List symbolSets = new(); private readonly HashSet squashedSymbolSets = new(); - private SymbolContext CurrentContext = - new() { ParentContext = new SymbolContext { ParentContext = null! } }; + private SymbolContext CurrentContext = new() + { + ParentContext = new SymbolContext { ParentContext = null! }, + }; private PreprocessorSymbols() : base(SyntaxWalkerDepth.Trivia) { } From b204505abd56de77a2ffa52965dee55fde265800 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Mon, 18 Nov 2024 18:23:30 -0600 Subject: [PATCH 7/9] fixing playground --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57dcd3ed1..142514c8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-bookworm-slim-amd64 AS base +FROM mcr.microsoft.com/dotnet/aspnet:9.0.0-bookworm-slim-amd64 AS base WORKDIR /app ENV ASPNETCORE_URLS=http://+:80 EXPOSE 80 -FROM mcr.microsoft.com/dotnet/sdk:8.0.100-bookworm-slim-amd64 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0.100-bookworm-slim-amd64 AS build RUN set -uex \ && apt-get update \ From 88e3d9b6dc1818485ac721d9b8d375d4de7c70e0 Mon Sep 17 00:00:00 2001 From: PetSerAl Date: Wed, 20 Nov 2024 08:11:15 +0300 Subject: [PATCH 8/9] Use current `dotnet` host instead of global (#1387) Use current `dotnet` binary from `DOTNET_HOST_PATH` instead of just `dotnet`. Reasons: 1. Global (in `PATH`) may not exist (when used _Binaries_, but not _Installers_). 2. Global can have different runtime version. 3. Consistent with outer tools (`csc` for example). https://github.com/dotnet/roslyn/blob/324fd25331c969cd742ba68eee09ffd4b6fd29e3/src/Compilers/Shared/RuntimeHostInfo.cs#L61-L64 4. It is documented to be used for that purpose. https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_host_path --- Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets b/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets index b9f292b3b..10d4787a6 100644 --- a/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets +++ b/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets @@ -4,6 +4,8 @@ net8.0 net8.0 $(MSBuildThisFileDirectory)../tools/csharpier/$(CSharpier_FrameworkVersion)/dotnet-csharpier.dll + $(DOTNET_HOST_PATH) + dotnet $(CSharpierArgs) --check $(CSharpierArgs) --loglevel $(CSharpier_LogLevel) $(TargetFramework) @@ -23,7 +25,7 @@ StdOutEncoding="utf-8" StdErrEncoding="utf-8" IgnoreExitCode="true" - Command="dotnet "$(CSharpierDllPath)" $(CSharpierArgs) --no-msbuild-check --compilation-errors-as-warnings "$(MSBuildProjectDirectory)" > $(NullOutput) " /> + Command=""$(CSharpier_dotnet_Path)" exec "$(CSharpierDllPath)" $(CSharpierArgs) --no-msbuild-check --compilation-errors-as-warnings "$(MSBuildProjectDirectory)" > $(NullOutput) " />