Skip to content

Commit 3ffe85c

Browse files
Convert project to SDK-style (#42)
* Convert project to SDK-style * Run Repack and create NuGet package during the build
1 parent 35a9ccb commit 3ffe85c

5 files changed

+48
-130
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,51 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
43
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{DB0F6F84-0028-4A9E-9EF6-60309AB51BAC}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>ILRepack.Lib.MSBuild.Task</RootNamespace>
11-
<AssemblyName>ILRepack.Lib.MSBuild.Task</AssemblyName>
12-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<NuGetPackageImportStamp>
15-
</NuGetPackageImportStamp>
4+
<TargetFramework>net472</TargetFramework>
5+
<Version>2.0.18.3</Version>
166
</PropertyGroup>
17-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18-
<DebugSymbols>true</DebugSymbols>
19-
<DebugType>full</DebugType>
20-
<Optimize>false</Optimize>
21-
<OutputPath>bin\Debug\</OutputPath>
22-
<DefineConstants>DEBUG;TRACE</DefineConstants>
23-
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
25-
</PropertyGroup>
26-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27-
<DebugType>none</DebugType>
28-
<Optimize>true</Optimize>
29-
<OutputPath>build\build\</OutputPath>
30-
<DefineConstants>TRACE</DefineConstants>
31-
<ErrorReport>prompt</ErrorReport>
32-
<WarningLevel>4</WarningLevel>
33-
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
34-
</PropertyGroup>
35-
<PropertyGroup>
36-
<SignAssembly>false</SignAssembly>
37-
</PropertyGroup>
38-
<PropertyGroup>
39-
<SolutionDir>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))\</SolutionDir>
40-
</PropertyGroup>
41-
<PropertyGroup>
42-
<AssemblyOriginatorKeyFile>
43-
</AssemblyOriginatorKeyFile>
44-
</PropertyGroup>
45-
<ItemGroup>
46-
<Reference Include="ILRepack, Version=2.0.18.0, Culture=neutral, PublicKeyToken=c3e9373f1c31208e, processorArchitecture=MSIL">
47-
<HintPath>..\packages\ILRepack.Lib.2.0.18\lib\net40\ILRepack.dll</HintPath>
48-
</Reference>
49-
<Reference Include="Microsoft.Build.Framework" />
50-
<Reference Include="Microsoft.Build.Utilities.v4.0" />
51-
<Reference Include="System" />
52-
<Reference Include="System.Core" />
53-
<Reference Include="System.Xml.Linq" />
54-
<Reference Include="System.Data.DataSetExtensions" />
55-
<Reference Include="Microsoft.CSharp" />
56-
<Reference Include="System.Data" />
57-
<Reference Include="System.Xml" />
58-
</ItemGroup>
7+
598
<ItemGroup>
60-
<Compile Include="ILRepack.cs" />
61-
<Compile Include="Logger.cs" />
62-
<Compile Include="Properties\AssemblyInfo.cs" />
9+
<PackageReference Include="ILRepack" Version="2.0.18" GeneratePathProperty="true" />
10+
<PackageReference Include="ILRepack.Lib" Version="2.0.18" />
11+
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.5.0" />
6312
</ItemGroup>
13+
6414
<ItemGroup>
6515
<None Include="build\ILRepack.Lib.MSBuild.Task.nuspec" />
66-
<None Include="ILRepack.Config.props">
67-
<SubType>Designer</SubType>
68-
</None>
16+
<None Include="ILRepack.Config.props" />
6917
<None Include="ILRepack.Lib.MSBuild.Task.snk" />
70-
<None Include="ILRepack.Lib.MSBuild.Task.targets">
71-
<SubType>Designer</SubType>
72-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
73-
</None>
74-
<None Include="packages.config">
75-
<SubType>Designer</SubType>
76-
</None>
18+
<None Include="ILRepack.Lib.MSBuild.Task.targets" CopyToOutputDirectory="PreserveNewest" />
7719
</ItemGroup>
78-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
79-
<Import Project="..\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets" Condition="Exists('..\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" />
80-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
20+
21+
<Target Name="Repack" AfterTargets="Build">
22+
<Exec Command="&quot;$(ILRepack)&quot; /out:ILRepack.Lib.MSBuild.Task.dll ILRepack.Lib.MSBuild.Task.dll ILRepack.dll"
23+
WorkingDirectory="$(OutDir)"
24+
ConsoleToMSBuild="True" />
25+
</Target>
26+
27+
<Target Name="PrepareNupkgInfo">
8128
<PropertyGroup>
82-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
29+
<NuspecPath>$(MSBuildThisFileDirectory)build\ILRepack.Lib.MSBuild.Task.nuspec</NuspecPath>
30+
<NupkgPath>$(OutDir)ILRepack.Lib.MSBuild.Task.$(Version).nupkg</NupkgPath>
8331
</PropertyGroup>
84-
<Error Condition="!Exists('..\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets'))" />
85-
</Target>
86-
<!--
87-
To modify your build process, add your task inside one of the targets below and uncomment it.
88-
Other similar extension points exist, see Microsoft.Common.targets.
89-
<Target Name="BeforeBuild">
9032
</Target>
91-
<Target Name="AfterBuild">
33+
34+
<Target Name="CreateNupkg"
35+
Condition="$(Configuration) == 'Release'"
36+
AfterTargets="Build"
37+
DependsOnTargets="Repack;PrepareNupkgInfo"
38+
Inputs="$(NuspecPath);$(TargetPath);$(MSBuildThisFileFullPath)"
39+
Outputs="$(NupkgPath)">
40+
<PackTask
41+
PackItem="$(NuspecPath)"
42+
NuspecFile="$(NuspecPath)"
43+
NuspecProperties="version=$(Version)"
44+
NuspecBasePath="$(OutDir)"
45+
NuspecOutputPath="$(NuspecOutputPath)"
46+
PackageOutputPath="$(OutDir)"
47+
RestoreOutputPath="$(RestoreOutputPath)"
48+
SymbolPackageFormat="snupkg" />
9249
</Target>
93-
-->
50+
9451
</Project>

ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.targets

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
2-
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project>
32
<Import Project="$(ProjectDir)ILRepack.Config.props" Condition="Exists('$(ProjectDir)ILRepack.Config.props')" />
4-
<Choose>
5-
<When Condition="'$(ILRepackTargetsFile)' == ''">
6-
<PropertyGroup>
7-
<ILRepackTargetsFile>$(ProjectDir)ILRepack.targets</ILRepackTargetsFile>
8-
</PropertyGroup>
9-
</When>
10-
</Choose>
3+
4+
<PropertyGroup>
5+
<ILRepackTargetsFile Condition="$(ILRepackTargetsFile) == ''">$(ProjectDir)ILRepack.targets</ILRepackTargetsFile>
6+
</PropertyGroup>
7+
118
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)ILRepack.Lib.MSBuild.Task.dll" TaskName="ILRepack" />
129
<Import Project="$(ILRepackTargetsFile)" Condition="Exists('$(ILRepackTargetsFile)')" />
1310
<Target Name="ILRepack" AfterTargets="Build" Condition="$(Configuration.Contains('Release')) and !Exists('$(ILRepackTargetsFile)')">

ILRepack.Lib.MSBuild.Task/Properties/AssemblyInfo.cs

-35
This file was deleted.

ILRepack.Lib.MSBuild.Task/build/ILRepack.Lib.MSBuild.Task.nuspec

+4
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@
1616
<language>en-US</language>
1717
<tags>ILRepack,MSBuild,ILMerge alternative,merge assemblies</tags>
1818
</metadata>
19+
<files>
20+
<file src="ILRepack.Lib.MSBuild.Task.dll" target="build" />
21+
<file src="ILRepack.Lib.MSBuild.Task.targets" target="build" />
22+
</files>
1923
</package>

ILRepack.Lib.MSBuild.Task/packages.config

-5
This file was deleted.

0 commit comments

Comments
 (0)