Skip to content

Commit

Permalink
#383: Use ILRepack due to conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Sep 6, 2023
1 parent 26ed962 commit 96555ae
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 28 deletions.
1 change: 1 addition & 0 deletions Versions.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>

<PropertyGroup>
<ILRepackVersion>2.0.13</ILRepackVersion>
<MicrosoftNetCoreAppRefVersion>6.0.11</MicrosoftNetCoreAppRefVersion>
<MicrosoftNetTestSdkVersion>17.7.0</MicrosoftNetTestSdkVersion>
<MicrosoftSourceLinkGitHubVersion>1.1.1</MicrosoftSourceLinkGitHubVersion>
Expand Down
106 changes: 78 additions & 28 deletions src/xunit.runner.visualstudio/xunit.runner.visualstudio.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
<Project Sdk="Microsoft.Net.SDK">

<PropertyGroup>
<Title>xUnit.net [Runner: Visual Studio]</Title>
<AssemblyTitle>xUnit.net Runner for Visual Studio ($(TargetFramework))</AssemblyTitle>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>Xunit.Runner.VisualStudio</RootNamespace>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<WarningsAsErrors>true</WarningsAsErrors>
<Description>Visual Studio 2022+ Test Explorer runner for the xUnit.net framework. Capable of running xUnit.net v1.9.2 and v2.0+ tests. Supports .NET 4.6.2 or later, and .NET 6 or later.</Description>
<DevelopmentDependency>true</DevelopmentDependency>
<BuildOutputTargetFolder>build</BuildOutputTargetFolder>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<CopyLocalLockFileAssemblies Condition=" '$(TargetFramework)' == 'net6.0' ">true</CopyLocalLockFileAssemblies>
<NoWarn>$(NoWarn);CS0436</NoWarn>
<Nullable>enable</Nullable>
<PackageIcon>_content/logo-128-transparent.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReadmeFile>_content/README.md</PackageReadmeFile>
<!-- Set the PackageId explicitly as our different AssemblyNames will cause restore errors otherwise -->
<PackageId>xunit.runner.visualstudio</PackageId>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
Expand All @@ -31,6 +23,7 @@
</PropertyGroup>

<ItemGroup>
<PackageDownload Include="ILRepack.MSBuild.Task" Version="[$(ILRepackVersion)]" />
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(MicrosoftNetCoreAppRefVersion)]" />
</ItemGroup>

Expand All @@ -41,25 +34,6 @@
<PackageReference Include="xunit.runner.reporters" Version="$(XunitVersion)" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Label="Package">
<None Include="build\xunit.runner.visualstudio.desktop.props" PackagePath="build\net462\xunit.runner.visualstudio.props" Pack="true" />
<None Include="$(NuGetPackageRoot)xunit.runner.reporters\$(XunitVersion)\lib\net452\*.dll" PackagePath="build\net462" Pack="true" Visible="false" />
<None Include="$(NuGetPackageRoot)xunit.runner.utility\$(XunitVersion)\lib\net452\*.dll" PackagePath="build\net462" Pack="true" Visible="false" />
<None Include="$(NuGetPackageRoot)xunit.abstractions\2.0.3\lib\netstandard1.0\*.dll" PackagePath="build\net462" Pack="true" Visible="false" />

<None Include="build\xunit.runner.visualstudio.dotnetcore.props" PackagePath="build\net6.0\xunit.runner.visualstudio.props" Pack="true" />
<None Include="$(NuGetPackageRoot)xunit.runner.reporters\$(XunitVersion)\lib\netcoreapp1.0\*.dll" PackagePath="build\net6.0" Pack="true" Visible="false" />
<None Include="$(NuGetPackageRoot)xunit.runner.utility\$(XunitVersion)\lib\netcoreapp1.0\*.dll" PackagePath="build\net6.0" Pack="true" Visible="false" />
<None Include="$(NuGetPackageRoot)xunit.abstractions\2.0.3\lib\netstandard2.0\*.dll" PackagePath="build\net6.0" Pack="true" Visible="false" />

<None Include="..\..\README.md" PackagePath="_content\README.md" Pack="true" Visible="false" />
<None Include="..\..\logo-128-transparent.png" PackagePath="_content\logo-128-transparent.png" Pack="true" Visible="false" />
<None Include="..\..\License.txt" PackagePath="License.txt" Pack="true" Visible="false" />

<None Include="build\_._" PackagePath="lib\net462" Pack="true" />
<None Include="build\_._" PackagePath="lib\net6.0" Pack="true" />
</ItemGroup>

<!-- Support deterministic builds (via https://github.com/clairernovotny/DeterministicBuilds) -->
<PropertyGroup>
<ContinuousIntegrationBuild Condition=" '$(GITHUB_ACTIONS)' == 'true' ">true</ContinuousIntegrationBuild>
Expand All @@ -82,4 +56,80 @@
</PropertyGroup>
</Target>

<Target Name="UpdateNuSpecProperties" BeforeTargets="GenerateNuspec" DependsOnTargets="GetBuildVersion">
<ReadLinesFromFile File="$(MSBuildThisFileDirectory)..\.git\modules\src\xunit.v3.assert\Asserts\HEAD">
<Output TaskParameter="Lines" PropertyName="GitAssertModuleCommitId"/>
</ReadLinesFromFile>
<PropertyGroup>
<!-- Local builds should have a '-dev' suffix on the build number -->
<PrereleaseSuffix Condition=" '$(GITHUB_ACTIONS)' != 'true' ">-dev</PrereleaseSuffix>
<!-- Pass through values we don't know ahead of time for any hand-crafted .nuspec files -->
<NuspecProperties>
Configuration=$(Configuration);
GitAssertModuleCommitId=$(GitAssertModuleCommitId);
GitCommitId=$(GitCommitId);
MicrosoftBclAsyncInterfacesVersion=$(MicrosoftBclAsyncInterfacesVersion);
MonoCecilVersion=$(MonoCecilVersion);
PackageVersion=$(PackageVersion);
SystemIoPipelinesVersion=$(SystemIoPipelinesVersion);
SystemNetHttpVersion=$(SystemNetHttpVersion);
SystemThreadingTasksExtensionsVersion=$(SystemThreadingTasksExtensionsVersion);
XunitAbstractionsVersion=$(XunitAbstractionsVersion);
XunitAnalyzersVersion=$(XunitAnalyzersVersion);
</NuspecProperties>
</PropertyGroup>
</Target>

<!-- ILRepack support -->
<Target
Name="ILRepack"
AfterTargets="Build"
Condition=" '$(TargetFramework)' != '' ">
<PropertyGroup>
<OutputAssembly>$([System.IO.Path]::Combine($(TargetDir), "merged", "$(TargetFileName)"))</OutputAssembly>
</PropertyGroup>

<Message Text="$(TargetName) -> $(OutputAssembly)" Importance="High" />
<CallTarget Targets="ILRepackConditional" />
</Target>

<Target
Name="ILRepackConditional"
Inputs="$(TargetPath)"
Outputs="$(TargetDir)merged\$(TargetFileName)">
<ItemGroup>
<ILRepackExclusions Include="$(OutputPath)*.abstractions.dll;$(OutputPath)Microsoft.*.dll;$(OutputPath)netstand*.dll;$(OutputPath)NuGet.*.dll;$(OutputPath)System.*.dll" />
</ItemGroup>
<ItemGroup>
<Assemblies
Include="$(TargetDir)*.dll;$(TargetPath)"
Exclude="@(ILRepackExclusions)" />
</ItemGroup>

<MakeDir Directories="$(TargetDir)premerge;$(TargetDir)merged" />
<!-- We copy assemblies into a 'premerge' folder and merge from there, because of this issue: https://github.com/gluck/il-repack/issues/283 -->
<Copy SourceFiles="@(Assemblies)" DestinationFolder="$(TargetDir)premerge" />

<PropertyGroup>
<ILRepackExe>$([System.IO.Path]::Combine($(NuGetPackageRoot), "ilrepack.msbuild.task", $(ILRepackVersion), "tools", "ilrepack.exe"))</ILRepackExe>
<ILRepackExe Condition=" '$(OS)' != 'Windows_NT' ">mono $(ILRepackExe)</ILRepackExe>
<MainAssembly>$([System.IO.Path]::Combine($(TargetDir), "premerge", "$(TargetFileName)"))</MainAssembly>
<OutputAssembly>$([System.IO.Path]::Combine($(TargetDir), "merged", "$(TargetFileName)"))</OutputAssembly>
</PropertyGroup>

<ItemGroup>
<OutputsToCopy Include="$(TargetDir)*.config;@(ILRepackExclusions)" />
<ILRepackDependencies
Include="$(TargetDir)premerge\*.dll"
Exclude="$(MainAssembly)"/>
</ItemGroup>

<Copy SourceFiles="@(OutputsToCopy)" DestinationFolder="$(TargetDir)merged" />
<Exec
StandardOutputImportance="low"
Command="$(ILRepackExe) -internalize -ndebug -lib:$(TargetDir) -out:$(OutputAssembly) $(MainAssembly) @(ILRepackDependencies, ' ')" />
<Exec Command="chmod +x '$(OutputAssembly)'" Condition=" '$(OS)' != 'Windows_NT' " />
<RemoveDir Directories="$(TargetDir)premerge" />
</Target>

</Project>
40 changes: 40 additions & 0 deletions src/xunit.runner.visualstudio/xunit.runner.visualstudio.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>xunit.runner.visualstudio</id>
<version>$PackageVersion$</version>
<title>xUnit.net [Runner: Visual Studio]</title>
<authors>jnewkirk,bradwilson</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">Apache-2.0</license>
<licenseUrl>https://licenses.nuget.org/Apache-2.0</licenseUrl>
<icon>_content/logo-128-transparent.png</icon>
<readme>_content/README.md</readme>
<releaseNotes>https://xunit.net/releases/visualstudio/$PackageVersion$</releaseNotes>
<description>Visual Studio 2022+ Test Explorer runner for the xUnit.net framework. Capable of running xUnit.net v1.9.2 and v2.0+ tests. Supports .NET 4.6.2 or later, and .NET 6 or later.</description>
<copyright>Copyright (C) .NET Foundation</copyright>
<repository type="git" url="https://github.com/xunit/xunit" commit="$GitCommitId$" />
<developmentDependency>true</developmentDependency>
<dependencies>
<group targetFramework="net462" />
<group targetFramework="net6.0" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="mscorlib" targetFramework="net462" />
</frameworkAssemblies>
</metadata>
<files>
<file target="_content\" src="..\..\logo-128-transparent.png" />
<file target="_content\" src="..\..\README.md" />

<file target="build\net462\" src="bin\$Configuration$\net462\merged\xunit.*.dll" />
<file target="build\net462\xunit.runner.visualstudio.props" src="build\xunit.runner.visualstudio.desktop.props" />

<file target="build\net6.0\" src="bin\$Configuration$\net6.0\merged\xunit.*.dll" />
<file target="build\net6.0\xunit.runner.visualstudio.props" src="build\xunit.runner.visualstudio.dotnetcore.props" />

<file target="lib\net462\" src="build\_._" />

<file target="lib\net6.0\" src="build\_._" />
</files>
</package>
15 changes: 15 additions & 0 deletions tools/builder/targets/Packages.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Threading.Tasks;
using Xunit.BuildTools.Models;

namespace Xunit.BuildTools.Targets;

public static partial class Packages
{
public static async Task OnExecute(BuildContext context)
{
context.BuildStep("Creating NuGet packages");

var packArgs = $"pack --nologo --no-build --configuration {context.ConfigurationText} --output {context.PackageOutputFolder} --verbosity {context.Verbosity} src/xunit.runner.visualstudio -p:NuspecFile=xunit.runner.visualstudio.nuspec";
await context.Exec("dotnet", packArgs);
}
}

0 comments on commit 96555ae

Please sign in to comment.