-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from kzu/main
Provide a dotnet global tool version of ilrepack
- Loading branch information
Showing
14 changed files
with
413 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Builds and runs tests in all three supported OSes | ||
# Pushes CI feed if secrets.SLEET_CONNECTION is provided | ||
|
||
name: build | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ main, dev, 'dev/*', 'feature/*', 'rel/*' ] | ||
paths-ignore: | ||
- changelog.md | ||
- code-of-conduct.md | ||
- security.md | ||
- support.md | ||
- readme.md | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
env: | ||
DOTNET_NOLOGO: true | ||
Configuration: Release | ||
PackageOutputPath: ${{ github.workspace }}/bin | ||
VersionPrefix: 42.42.${{ github.run_number }} | ||
VersionLabel: ${{ github.ref }} | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
runs-on: "windows-latest" | ||
steps: | ||
- name: 🤘 checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: ⚙ msbuild | ||
uses: microsoft/setup-msbuild@v2 | ||
|
||
- name: 🙏 build | ||
shell: pwsh | ||
run: msbuild /r /m /bl | ||
|
||
- name: 🧪 test | ||
run: dotnet test --no-build -l trx | ||
|
||
- name: 🗎 trx | ||
if: always() | ||
run: | | ||
dotnet tool install -g dotnet-trx | ||
trx | ||
- name: 📦 pack | ||
run: | | ||
dotnet pack --no-build ILRepack/ILRepack.csproj | ||
dotnet pack --no-build ILRepackTool/ILRepackTool.csproj | ||
- name: ⬆️ upload | ||
if: success() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pkg | ||
path: bin/* | ||
|
||
- name: 🐛 logs | ||
uses: actions/upload-artifact@v3 | ||
if: runner.debug && always() | ||
with: | ||
name: logs | ||
path: '*.binlog' | ||
|
||
- name: 🚀 sleet | ||
env: | ||
SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }} | ||
if: env.SLEET_CONNECTION != '' | ||
run: | | ||
dotnet tool install -g --version 4.0.18 sleet | ||
sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found" | ||
test-tool: | ||
name: test-${{ matrix.os }} | ||
needs: build | ||
runs-on: ${{ matrix.os }} | ||
defaults: | ||
run: | ||
shell: pwsh | ||
strategy: | ||
matrix: | ||
os: [ 'windows-latest', 'ubuntu-latest', 'macOS-latest' ] | ||
steps: | ||
- name: 🤘 checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: ⬇️ artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: pkg | ||
path: bin | ||
|
||
- name: ⚙ install | ||
working-directory: bin | ||
run: dotnet tool update -g dotnet-ilrepack --prerelease --add-source . | ||
|
||
- name: 🧪 run | ||
run: | | ||
ilrepack --version | ||
- name: 📦 ilrepack | ||
shell: pwsh | ||
working-directory: ILRepack.IntegrationTests/Scenarios/AnalyzerWithDependencies | ||
run: | | ||
dotnet build -c:Release -p:MergeAnalyzerAssemblies=false | ||
test-path bin/Release/netstandard2.0/Microsoft.IdentityModel.Abstractions.dll | Should -Be $true | ||
test-path bin/Release/netstandard2.0/Microsoft.IdentityModel.JsonWebTokens.dll | Should -Be $true | ||
test-path bin/Release/netstandard2.0/Microsoft.IdentityModel.Logging.dll | Should -Be $true | ||
test-path bin/Release/netstandard2.0/Microsoft.IdentityModel.Tokens.dll | Should -Be $true | ||
test-path bin/Release/netstandard2.0/System.Text.Encoding.CodePages.dll | Should -Be $true | ||
test-path bin/Release/netstandard2.0/System.Text.Encodings.Web.dll | Should -Be $true | ||
test-path bin/Release/netstandard2.0/System.Text.Json.dll | Should -Be $true | ||
# ensure the same assemblies are not present when ilrepack global tool is run | ||
dotnet build -c:Release -p:MergeAnalyzerAssemblies=true | ||
test-path bin/Release/netstandard2.0/Microsoft.IdentityModel.Abstractions.dll | Should -Be $false | ||
test-path bin/Release/netstandard2.0/Microsoft.IdentityModel.JsonWebTokens.dll | Should -Be $false | ||
test-path bin/Release/netstandard2.0/Microsoft.IdentityModel.Logging.dll | Should -Be $false | ||
test-path bin/Release/netstandard2.0/Microsoft.IdentityModel.Tokens.dll | Should -Be $false | ||
test-path bin/Release/netstandard2.0/System.Text.Encoding.CodePages.dll | Should -Be $false | ||
test-path bin/Release/netstandard2.0/System.Text.Encodings.Web.dll | Should -Be $false | ||
test-path bin/Release/netstandard2.0/System.Text.Json.dll | Should -Be $false | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Builds a final release version and pushes to nuget.org | ||
# whenever a release is published. | ||
# Requires: secrets.NUGET_API_KEY | ||
|
||
name: publish | ||
on: | ||
release: | ||
types: [prereleased, released] | ||
|
||
env: | ||
DOTNET_NOLOGO: true | ||
Configuration: Release | ||
PackageOutputPath: ${{ github.workspace }}/bin | ||
VersionLabel: ${{ github.ref }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: windows-latest | ||
steps: | ||
- name: 🤘 checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: ⚙ msbuild | ||
uses: microsoft/setup-msbuild@v2 | ||
|
||
- name: 🙏 build | ||
run: msbuild /r /m /bl | ||
|
||
- name: 🧪 test | ||
run: dotnet test --no-build -l trx | ||
|
||
- name: 🗎 trx | ||
if: always() | ||
run: | | ||
dotnet tool install -g dotnet-trx | ||
trx | ||
- name: 📦 pack | ||
run: | | ||
dotnet pack --no-build ILRepack/ILRepack.csproj | ||
dotnet pack --no-build ILRepackTool/ILRepackTool.csproj | ||
- name: 🚀 nuget | ||
env: | ||
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | ||
if: env.NUGET_API_KEY != '' | ||
run: dotnet nuget push ./bin/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,6 @@ _NCrunch* | |
*.ncrunchproject | ||
*.sln.cache | ||
*.DotSettings | ||
/.vs | ||
.vs | ||
/.idea | ||
*.binlog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
ILRepack.IntegrationTests/Scenarios/AnalyzerWithDependencies/AnalyzerWithDependencies.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<MergeAnalyzerAssemblies Condition="$(Configuration) == 'Release'">true</MergeAnalyzerAssemblies> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" /> | ||
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" /> | ||
</ItemGroup> | ||
|
||
<Target Name="ILRepack" AfterTargets="CoreCompile" BeforeTargets="CopyFilesToOutputDirectory" | ||
Inputs="@(IntermediateAssembly -> '%(FullPath)')" | ||
Outputs="$(IntermediateOutputPath)ilrepack.txt" | ||
Returns="@(MergedAssemblies)" | ||
Condition="Exists(@(IntermediateAssembly -> '%(FullPath)')) And '$(MergeAnalyzerAssemblies)' == 'true'"> | ||
<ItemGroup> | ||
<ReferenceCopyLocalAssemblies Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.dll' | ||
And !$([MSBuild]::ValueOrDefault('%(FileName)', '').EndsWith('.resources', StringComparison.OrdinalIgnoreCase))" /> | ||
<MergedAssemblies Include="@(ReferenceCopyLocalAssemblies)" Condition=" | ||
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CodeAnalysis', StringComparison.OrdinalIgnoreCase)) And | ||
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CSharp', StringComparison.OrdinalIgnoreCase)) And | ||
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.', StringComparison.OrdinalIgnoreCase))" | ||
/> | ||
<!-- Brings in System/Microsoft.IdentityModel, System.Text.Encodings.Web, System.Text.Json --> | ||
<MergedAssemblies Include="@(ReferenceCopyLocalAssemblies)" Condition=" | ||
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.IdentityModel', StringComparison.OrdinalIgnoreCase)) Or | ||
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.IdentityModel', StringComparison.OrdinalIgnoreCase)) Or | ||
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.Text', StringComparison.OrdinalIgnoreCase))" | ||
/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ReferenceCopyLocalDirs Include="@(ReferenceCopyLocalPaths -> '%(RootDir)%(Directory)')" /> | ||
<ReferenceCopyLocalPaths Remove="@(MergedAssemblies)" /> | ||
<LibDir Include="@(ReferenceCopyLocalDirs -> Distinct())" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<AbsoluteAssemblyOriginatorKeyFile Condition="'$(AssemblyOriginatorKeyFile)' != ''">$([System.IO.Path]::GetFullPath($([System.IO.Path]::Combine('$(MSBuildProjectDirectory)','$(AssemblyOriginatorKeyFile)'))))</AbsoluteAssemblyOriginatorKeyFile> | ||
<ILRepackArgs Condition="'$(AbsoluteAssemblyOriginatorKeyFile)' != ''">/keyfile:"$(AbsoluteAssemblyOriginatorKeyFile)" /delaysign</ILRepackArgs> | ||
<ILRepackArgs>$(ILRepackArgs) /internalize</ILRepackArgs> | ||
<ILRepackArgs>$(ILRepackArgs) /union</ILRepackArgs> | ||
<!-- This is needed to merge types with identical names into one, wich happens with IFluentInterface in Merq and Merq.Core (Xamarin.Messaging dependencies) --> | ||
<ILRepackArgs>$(ILRepackArgs) @(LibDir -> '/lib:"%(Identity)."', ' ')</ILRepackArgs> | ||
<ILRepackArgs>$(ILRepackArgs) /out:"@(IntermediateAssembly -> '%(FullPath)')"</ILRepackArgs> | ||
<ILRepackArgs>$(ILRepackArgs) "@(IntermediateAssembly -> '%(FullPath)')"</ILRepackArgs> | ||
<ILRepackArgs>$(ILRepackArgs) @(MergedAssemblies -> '"%(FullPath)"', ' ')</ILRepackArgs> | ||
</PropertyGroup> | ||
|
||
<!-- Run dotnet global tool version of ilrepack --> | ||
<Exec Command='ilrepack $(ILRepackArgs)' WorkingDirectory="$(MSBuildProjectDirectory)\$(OutputPath)" StandardErrorImportance="high" IgnoreStandardErrorWarningFormat="true" StandardOutputImportance="low" ConsoleToMSBuild="true" ContinueOnError="true"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="ILRepackOutput" /> | ||
<Output TaskParameter="ExitCode" PropertyName="ExitCode" /> | ||
</Exec> | ||
<Message Importance="high" Text="$(ILRepackOutput)" Condition="'$(ExitCode)' != '0'" /> | ||
<Delete Files="$(IntermediateOutputPath)ilrepack.txt" Condition="'$(ExitCode)' != '0'" /> | ||
<Touch AlwaysCreate="true" Files="$(IntermediateOutputPath)ilrepack.txt" Condition="'$(ExitCode)' == '0'" /> | ||
<Error Text="$(ILRepackOutput)" Condition="'$(ExitCode)' != '0' And '$(ContinueOnError)' != 'true'" /> | ||
<ItemGroup> | ||
<MergedAssembliesToRemove Include="@(MergedAssemblies)" /> | ||
<MergedAssembliesToRemove Remove="@(ReferenceToPreserve)" /> | ||
</ItemGroup> | ||
<Delete Files="@(MergedAssembliesToRemove -> '$(MSBuildProjectDirectory)\$(OutputPath)%(Filename)%(Extension)')" Condition="Exists('$(MSBuildProjectDirectory)\$(OutputPath)%(Filename)%(Extension)')" /> | ||
</Target> | ||
|
||
</Project> |
30 changes: 30 additions & 0 deletions
30
ILRepack.IntegrationTests/Scenarios/AnalyzerWithDependencies/SampleAnalyzer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Immutable; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.IdentityModel.JsonWebTokens; | ||
|
||
namespace AnalyzerWithDependencies; | ||
|
||
[DiagnosticAnalyzer(LanguageNames.CSharp)] | ||
public class SampleAnalyzer : DiagnosticAnalyzer | ||
{ | ||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [ | ||
new DiagnosticDescriptor("AWD001", "Sample analyzer", "Hello {0}", "Design", DiagnosticSeverity.Warning, isEnabledByDefault: true)]; | ||
|
||
public override void Initialize(AnalysisContext context) | ||
{ | ||
context.EnableConcurrentExecution(); | ||
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); | ||
|
||
context.RegisterCompilationAction(ctx => | ||
{ | ||
var compilation = ctx.Compilation; | ||
// Exercise some external dependency | ||
var token = new JsonWebToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"); | ||
var name = token.GetPayloadValue<string>("name"); | ||
var diagnostic = Diagnostic.Create(SupportedDiagnostics[0], Location.None, name); | ||
ctx.ReportDiagnostic(diagnostic); | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
ILRepack.IntegrationTests/Scenarios/AnalyzerWithDependencies/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Exercises the dotnet-ilrepack tool instead of the ilrepack.exe | ||
|
||
Requires the dotnet-ilrepack tool to be installed. Before compiling. |
Oops, something went wrong.