Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port StrongNamer to a .NET Standard MSBuild task. #31

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions common/CommonAssemblyInfo.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/StrongNamer/Properties/AssemblyInfo.cs

This file was deleted.

113 changes: 50 additions & 63 deletions src/StrongNamer/StrongNamer.csproj
Original file line number Diff line number Diff line change
@@ -1,72 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3BED6CCE-6803-448D-90D7-86EB9699CEA7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StrongNamer</RootNamespace>
<AssemblyName>StrongNamer</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetRuntimeIdentifier>win-any</NuGetRuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<!-- makes this sample work when compiling on macOS and Linux because .NET Framework is not available -->
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<PackageOutputPath>$(MSBuildThisFileDirectory)..\..\artifacts\</PackageOutputPath>
<!-- Suppresses the warnings about the package not having assemblies in lib/*/.dll.-->
<NoPackageAnalysis>true</NoPackageAnalysis>
<!-- Change the default location where NuGet will put the build output -->
<BuildOutputTargetFolder>tasks</BuildOutputTargetFolder>
<!-- set the version automatically -->
<VersionPrefix>0.0.8</VersionPrefix>
<VersionSuffix>build$([System.DateTime]::Now.ToString('yyyyMMdd-HHmm'))</VersionSuffix>
</PropertyGroup>

<ItemGroup>
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Tasks.v4.0" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Content Include="build\*" PackagePath="build\">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="buildMultiTargeting\*" PackagePath="buildMultiTargeting\" />
<Content Update="build\SharedKey.snk" PackagePath="build\">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\common\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AddStrongName.cs" />
<Compile Include="StrongNamerAssemblyResolver.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<PackageReference Include="Microsoft.Build.Framework" Version="15.8.166" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.8.166" />
<!-- Marks all packages as 'local only' so they don't end up in the nuspec. -->
<PackageReference Update="@(PackageReference)" PrivateAssets="All" />
<PackageReference Include="Mono.Cecil" Version="0.10.1" />
</ItemGroup>

<ItemGroup>
<None Include="project.json" />
<None Include="SharedKey.snk">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="StrongNamer.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</None>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>

<Target Name="PackTaskDependencies" BeforeTargets="GenerateNuspec">
<!--
The include needs to happen after output has been copied to build output folder
but before NuGet generates a nuspec.
From a workaround described at https://github.com/NuGet/Home/issues/5063
-->
</Project>
<ItemGroup>
<_PackageFiles Include="bin\$(Configuration)\**\Mono.Cecil.dll">
<PackagePath>tasks\netstandard2.0\Mono.Cecil.dll</PackagePath>
<Visible>false</Visible>
<BuildAction>Content</BuildAction>
</_PackageFiles>
<_PackageFiles Include="bin\$(Configuration)\**\Mono.Cecil.dll">
<PackagePath>tasks\net461\Mono.Cecil.dll</PackagePath>
<Visible>false</Visible>
<BuildAction>Content</BuildAction>
</_PackageFiles>
</ItemGroup>
</Target>

</Project>
File renamed without changes.
7 changes: 7 additions & 0 deletions src/StrongNamer/build/StrongNamer.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
This file is automatically imported by NuGet into a user's project
when it targets a single framework, or in classic (pre 2017) csproj projects.
-->
<Project>

</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="StrongNamer.AddStrongName" AssemblyFile="$(MSBuildThisFileDirectory)StrongNamer.dll" />
<Project TreatAsLocalProperty="TaskFolder;TaskAssembly">

<PropertyGroup>
<TaskFolder Condition=" '$(MSBuildRuntimeType)' == 'Core' ">netstandard2.0</TaskFolder>
<TaskFolder Condition=" '$(MSBuildRuntimeType)' != 'Core' ">net461</TaskFolder>
<TaskAssembly>$(MSBuildThisFileDirectory)..\tasks\$(TaskFolder)\StrongNamer.dll</TaskAssembly>
</PropertyGroup>

<UsingTask TaskName="StrongNamer.AddStrongName" AssemblyFile="$(TaskAssembly)" />

<Target Name="StrongNamerTarget"
AfterTargets="AfterResolveReferences"
Condition="'$(DisableStrongNamer)' != 'true'">

<PropertyGroup>
<StrongNamerKeyFile Condition="'$(StrongNamerKeyFile)'==''">$(MSBuildThisFileDirectory)SharedKey.snk</StrongNamerKeyFile>
<StrongNamerKeyFile Condition="'$(StrongNamerKeyFile)'==''">$(MSBuildThisFileDirectory)SharedKey.snk</StrongNamerKeyFile>
</PropertyGroup>

<StrongNamer.AddStrongName
Expand All @@ -18,7 +25,6 @@

<Output TaskParameter="SignedAssembliesToReference" ItemName="AssembliesToReference" />
<Output TaskParameter="NewCopyLocalFiles" ItemName="NewCopyLocalFiles" />

</StrongNamer.AddStrongName>

<ItemGroup>
Expand All @@ -28,11 +34,9 @@
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
<ReferenceCopyLocalPaths Include="@(NewCopyLocalFiles)" />
</ItemGroup>

</Target>

<PropertyGroup>
<ResolveReferencesDependsOn>$(ResolveReferencesDependsOn);StrongNamerTarget</ResolveReferencesDependsOn>
</PropertyGroup>

</Project>
</Project>
7 changes: 7 additions & 0 deletions src/StrongNamer/buildMultiTargeting/StrongNamer.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
This file is automatically imported by NuGet into a user's project
when it targets multiple frameworks, e.g. <TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
-->
<Project>
<Import Project="..\build\StrongNamer.targets" />
</Project>
4 changes: 0 additions & 4 deletions src/StrongNamer/packages.config

This file was deleted.

13 changes: 0 additions & 13 deletions src/StrongNamer/project.json

This file was deleted.