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

Packaging improvements #19

Merged
merged 1 commit into from Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 32 additions & 13 deletions Directory.Build.props
Expand Up @@ -4,35 +4,39 @@
<SourceRoot>$(MSBuildThisFileDirectory)</SourceRoot>
</PropertyGroup>

<!-- Packaging -->
<PropertyGroup>
<Authors>Reuben Bond</Authors>
<Product>Hagar</Product>
<VersionPrefix>0.0.1</VersionPrefix>
<VersionPrefix>0.2.1</VersionPrefix>
<Copyright>Copyright © Reuben Bond 2018</Copyright>
<!--
<PackageLicenseUrl>https://github.com/dotnet/Orleans#license</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/dotnet/Orleans</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/ReubenBond/Hagar/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/ReubenBond/Hagar</PackageProjectUrl>
<PackageIconUrl>https://raw.githubusercontent.com/dotnet/orleans/gh-pages/assets/logo_128.png</PackageIconUrl>
<PackageTags>Orleans Cloud-Computing Actor-Model Actors Distributed-Systems C# .NET</PackageTags>
<PackageTags>Serializer Span</PackageTags>
<PackageReleaseNotes></PackageReleaseNotes>
<RepositoryUrl>https://github.com/dotnet/Orleans</RepositoryUrl>
-->
<RepositoryUrl>https://github.com/ReubenBond/Hagar</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<IncludeSymbols>true</IncludeSymbols>
<IncludeSource>true</IncludeSource>
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<DefaultLanguage>en-US</DefaultLanguage>
<LangVersion>latest</LangVersion>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<!-- Strong Naming -->
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyFile>$(SourceRoot)SigningKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<!-- Common compile parameters -->
<PropertyGroup>
<LangVersion>latest</LangVersion>
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
<NoWarn>$(NoWarn);1591;FS2003</NoWarn>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
Expand All @@ -48,9 +52,24 @@
<PackageOutputPath Condition=" '$(PackageOutputPath)'=='' ">$(SourceRoot)/Artifacts/$(Configuration)</PackageOutputPath>
</PropertyGroup>

<!-- SourceLink -->
<ItemGroup>
<PackageReference Include="SourceLink.Create.GitHub" Version="2.8.3" PrivateAssets="All" />
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.8.3" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.8.3" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02 " PrivateAssets="All" />
</ItemGroup>

<!-- Solution bootstrapping for code generation -->
<PropertyGroup Condition=" '$(HagarCodeGen)' == 'true' ">
<HagarCodeGenCoreAssembly>$(MSBuildThisFileDirectory)src/Hagar.CodeGenerator.MSBuild.Bootstrap/bin/publish/$(Configuration)/netcoreapp2.1/Hagar.CodeGenerator.MSBuild.Bootstrap.dll</HagarCodeGenCoreAssembly>
</PropertyGroup>
<ItemGroup Condition=" '$(HagarCodeGen)' == 'true' ">
<ProjectReference Include="$(MSBuildThisFileDirectory)src/Hagar.CodeGenerator.MSBuild.Bootstrap/Hagar.CodeGenerator.MSBuild.Bootstrap.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<AssetTargetFallback>netcoreapp2.1</AssetTargetFallback>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<UndefineProperties>TargetFramework</UndefineProperties>
<HagarCodeGen>false</HagarCodeGen>
</ProjectReference>
</ItemGroup>
<!-- End -->

</Project>
18 changes: 0 additions & 18 deletions Directory.Build.targets

This file was deleted.

7 changes: 7 additions & 0 deletions Hagar.sln
Expand Up @@ -45,6 +45,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hagar.CodeGenerator.MSBuild.Tasks", "src\Hagar.CodeGenerator.MSBuild.Tasks\Hagar.CodeGenerator.MSBuild.Tasks.csproj", "{5656539A-233B-45BC-ADF1-9C804820FFCC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -99,6 +101,10 @@ Global
{6023811E-B6F6-4879-ABB2-77515FEA6C5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6023811E-B6F6-4879-ABB2-77515FEA6C5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6023811E-B6F6-4879-ABB2-77515FEA6C5F}.Release|Any CPU.Build.0 = Release|Any CPU
{5656539A-233B-45BC-ADF1-9C804820FFCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5656539A-233B-45BC-ADF1-9C804820FFCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5656539A-233B-45BC-ADF1-9C804820FFCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5656539A-233B-45BC-ADF1-9C804820FFCC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -116,6 +122,7 @@ Global
{1FCCA413-929B-447A-839D-E69510E9C1E5} = {2A14EA5B-AB5E-4486-A746-B834A1C0F290}
{633EF412-DF66-4FD5-8D0B-D5CD91E1D208} = {2A14EA5B-AB5E-4486-A746-B834A1C0F290}
{6023811E-B6F6-4879-ABB2-77515FEA6C5F} = {9CA57753-5824-4D32-825A-F9D0C6CABFBA}
{5656539A-233B-45BC-ADF1-9C804820FFCC} = {2A14EA5B-AB5E-4486-A746-B834A1C0F290}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8125413B-1B31-40F0-BA6B-BFD0C6925F6C}
Expand Down
9 changes: 3 additions & 6 deletions src/Hagar.Abstractions/Hagar.Abstractions.csproj
@@ -1,12 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Hagar</RootNamespace>
<PackageDescription>Fast, flexible, and version-tolerant serializer for .NET</PackageDescription>
</PropertyGroup>

<ItemGroup>
<PackageReference Update="SourceLink.Create.GitHub" Version="2.8.3" />
</ItemGroup>

</Project>
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build;PostBuildPublish">

<PropertyGroup>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netcoreapp2.1;net47</TargetFrameworks>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifier Condition=" '$(OS)' == 'Windows_NT' ">win10-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
Expand All @@ -27,6 +26,7 @@
<Visible>false</Visible>
</Compile>
<ProjectReference Include="..\Hagar.CodeGenerator\Hagar.CodeGenerator.csproj" PrivateAssets="all" />
<ProjectReference Include="..\Hagar.CodeGenerator.MSBuild.Tasks\Hagar.CodeGenerator.MSBuild.Tasks.csproj" PrivateAssets="all" Publish="true" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -62,7 +62,6 @@
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
<PackageReference Update="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Update="SourceLink.Create.GitHub" Version="2.8.3" />
</ItemGroup>

<Target Name="PostBuildPublish" AfterTargets="Build">
Expand Down
51 changes: 51 additions & 0 deletions src/Hagar.CodeGenerator.MSBuild.Tasks/DotNetMuxer.cs
@@ -0,0 +1,51 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;

namespace Hagar.CodeGenerator.MSBuild.Tasks
{
/// <summary>
/// Utilities for finding the "dotnet.exe" file from the currently running .NET Core application
/// </summary>
internal static class DotNetMuxer
{
private const string MuxerName = "dotnet";

static DotNetMuxer()
{
MuxerPath = TryFindMuxerPath();
}

/// <summary>
/// The full filepath to the .NET Core muxer.
/// </summary>
public static string MuxerPath { get; }

/// <summary>
/// Finds the full filepath to the .NET Core muxer,
/// or returns a string containing the default name of the .NET Core muxer ('dotnet').
/// </summary>
/// <returns>The path or a string named 'dotnet'.</returns>
public static string MuxerPathOrDefault()
=> MuxerPath ?? MuxerName;

private static string TryFindMuxerPath()
{
var fileName = MuxerName;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
fileName += ".exe";
}

var mainModule = Process.GetCurrentProcess().MainModule;
if (!string.IsNullOrEmpty(mainModule?.FileName)
&& Path.GetFileName(mainModule.FileName).Equals(fileName, StringComparison.OrdinalIgnoreCase))
{
return mainModule.FileName;
}

return null;
}
}
}
19 changes: 19 additions & 0 deletions src/Hagar.CodeGenerator.MSBuild.Tasks/GetDotNetHost.cs
@@ -0,0 +1,19 @@
using Microsoft.Build.Framework;
using MSBuildTask = Microsoft.Build.Utilities.Task;

namespace Hagar.CodeGenerator.MSBuild.Tasks
{
public class GetDotNetHost : MSBuildTask
{
[Output]
public string DotNetHost { get; set; }

public override bool Execute()
{
this.DotNetHost = TryFindDotNetExePath();
return true;
}

private static string TryFindDotNetExePath() => DotNetMuxer.MuxerPathOrDefault();
}
}
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.5.180" />
</ItemGroup>
</Project>
23 changes: 11 additions & 12 deletions src/Hagar.CodeGenerator.MSBuild/Hagar.CodeGenerator.MSBuild.csproj
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build">

<PropertyGroup>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.1</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netcoreapp2.1;net47</TargetFrameworks>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PackageDescription>Code generator for projects using Hagar with MSBuild</PackageDescription>
<OutputType>Exe</OutputType>
<NoPackageAnalysis>true</NoPackageAnalysis>
<BuildOutputTargetFolder>tasks</BuildOutputTargetFolder>
Expand All @@ -17,10 +17,6 @@
<PublishDir>$(PublishRoot)$(TargetFramework)</PublishDir>
</PropertyGroup>

<ItemGroup>
<Content Include="prefercliruntime" />
</ItemGroup>

<ItemGroup>
<Content Include="build\Hagar.CodeGenerator.MSBuild.targets">
<Pack>true</Pack>
Expand All @@ -36,8 +32,9 @@

<ItemGroup>
<ProjectReference Include="..\Hagar.CodeGenerator\Hagar.CodeGenerator.csproj" PrivateAssets="all" />
<ProjectReference Include="..\Hagar.CodeGenerator.MSBuild.Tasks\Hagar.CodeGenerator.MSBuild.Tasks.csproj" PrivateAssets="all" Publish="true" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="15.5.180" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.5.180" />
Expand All @@ -57,7 +54,7 @@
<PackageReference Include="Microsoft.Win32.Primitives" Version="4.3.0" />
<PackageReference Include="System.Security.Principal" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="@(PackageReference)" PrivateAssets="All" Publish="true" />
<PackageReference Update="Microsoft.Build" Version="15.8.166" />
Expand All @@ -71,29 +68,31 @@
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
<PackageReference Update="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Update="SourceLink.Create.GitHub" Version="2.8.3" />
</ItemGroup>

<Target Name="PostBuildPublish" AfterTargets="Build">
<!-- So that we can create a nuget package which includes all dependencies, we publish the build. -->
<!-- However, we cannot publish during the cross-targeting build, so we skip that. -->
<CallTarget Targets="Publish" Condition="'$(TargetFramework)' != '' and '$(DesignTimeBuild)' == ''" />
</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. See https://github.com/NuGet/Home/issues/4704.
-->
<ItemGroup>
<PublishedFiles Include="$(PublishRoot)**/*" Exclude="$(PublishRoot)**/$(AssemblyName).*;$(PublishRoot)*/refs/**/*" />
<PublishedFiles Include="$(PublishRoot)**/$(AssemblyName).deps.json" />
<PublishedFiles Include="$(PublishRoot)**/$(AssemblyName).*.config" />
<PublishedFiles Include="$(PublishRoot)**/$(AssemblyName).dll.config" />
<PublishedFiles Include="$(PublishRoot)**/$(AssemblyName).Tasks.*" />

<_PackageFiles Include="@(PublishedFiles)">
<PackagePath>tasks/$(RecursiveDir)</PackagePath>
<Visible>false</Visible>
<BuildAction>Content</BuildAction>
</_PackageFiles>
</ItemGroup>
</Target>

</Project>