Skip to content

Commit

Permalink
Fix old .csproj fails to install Akka.Analyzers (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Dec 2, 2024
1 parent 1231b43 commit 433f7df
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Custom
tools/
.nuget/
.dotnet/
.idea/
Expand Down Expand Up @@ -39,7 +38,6 @@ bld/

#FAKE
.fake
tools/

#DocFx output
_site/
Expand Down
22 changes: 22 additions & 0 deletions src/Akka.Analyzers.Fixes/tools/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
param($installPath, $toolsPath, $package, $project)

if($project.Object.SupportsPackageDependencyResolution)
{
if($project.Object.SupportsPackageDependencyResolution())
{
# Do not install analyzers via install.ps1, instead let the project system handle it.
return
}
}

$analyzersPath = Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers\dotnet\roslyn3.11\cs"
if (Test-Path $analyzersPath)
{
foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll)
{
if($project.Object.AnalyzerReferences)
{
$project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
}
}
}
22 changes: 22 additions & 0 deletions src/Akka.Analyzers.Fixes/tools/uninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
param($installPath, $toolsPath, $package, $project)

if($project.Object.SupportsPackageDependencyResolution)
{
if($project.Object.SupportsPackageDependencyResolution())
{
# Do not uninstall analyzers via uninstall.ps1, instead let the project system handle it.
return
}
}

$analyzersPath = Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers\dotnet\roslyn3.11\cs"
if (Test-Path $analyzersPath)
{
foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll)
{
if($project.Object.AnalyzerReferences)
{
$project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
}
}
}
1 change: 1 addition & 0 deletions src/Akka.Analyzers.NuGet/Akka.Analyzers.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<files>
<file target="\" src="..\..\README.md" />
<file target="\" src="..\..\logo.png" />
<file target="tools\" src="..\Akka.Analyzers.Fixes\tools\*.ps1" />

<file target="analyzers\dotnet\roslyn4.8\cs\" src="..\Akka.Analyzers\bin\$Configuration$\netstandard2.0\Akka.Analyzers.dll" />
<file target="analyzers\dotnet\roslyn4.8\cs\" src="..\Akka.Analyzers.Fixes\bin\$Configuration$\netstandard2.0\Akka.Analyzers.Fixes.dll" />
Expand Down

0 comments on commit 433f7df

Please sign in to comment.