Skip to content

Commit 433f7df

Browse files
authored
Fix old .csproj fails to install Akka.Analyzers (#107)
1 parent 1231b43 commit 433f7df

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Custom
2-
tools/
32
.nuget/
43
.dotnet/
54
.idea/
@@ -39,7 +38,6 @@ bld/
3938

4039
#FAKE
4140
.fake
42-
tools/
4341

4442
#DocFx output
4543
_site/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
param($installPath, $toolsPath, $package, $project)
2+
3+
if($project.Object.SupportsPackageDependencyResolution)
4+
{
5+
if($project.Object.SupportsPackageDependencyResolution())
6+
{
7+
# Do not install analyzers via install.ps1, instead let the project system handle it.
8+
return
9+
}
10+
}
11+
12+
$analyzersPath = Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers\dotnet\roslyn3.11\cs"
13+
if (Test-Path $analyzersPath)
14+
{
15+
foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll)
16+
{
17+
if($project.Object.AnalyzerReferences)
18+
{
19+
$project.Object.AnalyzerReferences.Add($analyzerFilePath.FullName)
20+
}
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
param($installPath, $toolsPath, $package, $project)
2+
3+
if($project.Object.SupportsPackageDependencyResolution)
4+
{
5+
if($project.Object.SupportsPackageDependencyResolution())
6+
{
7+
# Do not uninstall analyzers via uninstall.ps1, instead let the project system handle it.
8+
return
9+
}
10+
}
11+
12+
$analyzersPath = Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers\dotnet\roslyn3.11\cs"
13+
if (Test-Path $analyzersPath)
14+
{
15+
foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll)
16+
{
17+
if($project.Object.AnalyzerReferences)
18+
{
19+
$project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
20+
}
21+
}
22+
}

src/Akka.Analyzers.NuGet/Akka.Analyzers.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<files>
2020
<file target="\" src="..\..\README.md" />
2121
<file target="\" src="..\..\logo.png" />
22+
<file target="tools\" src="..\Akka.Analyzers.Fixes\tools\*.ps1" />
2223

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

0 commit comments

Comments
 (0)