Skip to content

Instantly share code, notes, and snippets.

@harikmenon
Last active August 4, 2016 23:20
Show Gist options
  • Save harikmenon/ee72194925985ed7f4eb80b517972369 to your computer and use it in GitHub Desktop.
Save harikmenon/ee72194925985ed7f4eb80b517972369 to your computer and use it in GitHub Desktop.

At RTM, we are propsing that we support 2 ways of packing.

A) dotnet pack / nuget pack with csproj+ project.json [Does not support advanced scenarios; Recommmended for majority of users]

B) dotnet pack / nuget pack with convention based layout + nuspec [Advanced scenarios: bait and switch, contentFiles]

Option A

<?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')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <OutputType>WinExe</OutputType>
    <AssemblyName>WpfApplication3</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup>

    <!--This is optional since today we get this info from Assemblyinfo.cs-->


    <Id>Microsoft.AspNetCore.Server.Kestrel</Id>
    <Version>1.0.0</Version>
    <Authors>Microsoft.AspNetCore.Server.Kestrel</Authors>
    <Owners>Microsoft.AspNetCore.Server.Kestrel</Owners>
    <Description>ASP.NET Core Kestrel cross-platform web server.</Description>
    <Copyright>Copyright © Microsoft Corporation</Copyright>


    <!--These are other optional but recommnded properties to have in nupkgs-->
    <Summary>yadayada</Summary>
    <RequireLicenseAcceptance>true</RequireLicenseAcceptance>
    <LicenseUrl>http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</LicenseUrl>
    <ProjectUrl>http://www.asp.net/</ProjectUrl>
    <IconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</IconUrl>
    <Tags>aspnetcore,kestrel</Tags>
    <ReleaseNotes>aspnetcore,kestrel</ReleaseNotes>

    <!--These are in project.json packOptions that we will consider adding to -->
    <Repository/>
    <RepositoryType/>

    <!--Properties we are not bringing across from nuspec -->
    <Title></Title>
  </PropertyGroup>
  <ItemGroup>

    <!--Pack immutable content into project using exisitng content items-->
    <Content Include="ReadMe.txt">
    </Content>
    <Content Include="..\win7-x86\libuv.dll">
      <Pack>True</Pack>
      <PackagePath>runtimes\win7-x86\native\</PackagePath>
    </Content>
    <Content Include="..\win7-x64\libuv.dll">
      <Pack>True</Pack>
      <PackagePath>runtimes\win7-x64\native\</PackagePath>
    </Content>


    <!--Alternatively you can also use PackInclude to include items that arent in the project. This will provide te same funcitonality as Files in nuspec and
    Include/exlude/includefiles/excludefiles/mappings in project.json-->
    <PackContent Include="ReadMe.txt" />
    <PackContent Include="..\win7-x86\libuv.dll">
      <PackagePath>runtimes\win7-x86\native\</PackagePath>
    </PackContent>
    <PackContent Include="..\win7-x64\libuv.dll">
      <PackagePath>runtimes\win7-x64\native\</PackagePath>
    </PackContent>


    <!--Content goes into targets file-->
    <IncludeContentInPack Condition="'$(IncludeContentInPack)'==''">true</IncludeContentInPack>
    <PackContent Include="@Content" Condition="'$(IncludeContentInPack)'=='true'" />

  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Option B

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>Microsoft.AspNetCore.Server.Kestrel</id>
    <version>1.0.0</version>
    <authors>Microsoft.AspNetCore.Server.Kestrel</authors>
    <owners>Microsoft.AspNetCore.Server.Kestrel</owners>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <licenseUrl>http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm</licenseUrl>
    <projectUrl>http://www.asp.net/</projectUrl>
    <iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>
    <description>ASP.NET Core Kestrel cross-platform web server.</description>
    <copyright>Copyright © Microsoft Corporation</copyright>
    <tags>aspnetcore,kestrel</tags>
    <serviceable>true</serviceable>
    <dependencies>
      <group targetFramework=".NETFramework4.5.1">
        <dependency id="System.Buffers" version="4.0.0" />
        <dependency id="System.Numerics.Vectors" version="4.1.1" />
        <dependency id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" />
        <dependency id="System.Threading.Tasks.Extensions" version="4.0.0" />
        <dependency id="Libuv" version="1.9.0" />
        <dependency id="Microsoft.AspNetCore.Hosting" version="1.0.0" />
        <dependency id="Microsoft.Extensions.Logging.Abstractions" version="1.0.0" />
      </group>
      <group targetFramework=".NETStandard1.3">
        <dependency id="System.Collections" version="4.0.11" />
        <dependency id="System.Diagnostics.Debug" version="4.0.11" />
        <dependency id="System.Globalization" version="4.0.11" />
        <dependency id="System.IO" version="4.1.0" />
        <dependency id="System.Linq" version="4.1.0" />
        <dependency id="System.Net.Primitives" version="4.0.11" />
        <dependency id="System.Runtime.Extensions" version="4.1.0" />
        <dependency id="System.Runtime.InteropServices" version="4.1.0" />
        <dependency id="System.Text.Encoding" version="4.0.11" />
        <dependency id="System.Threading" version="4.0.11" />
        <dependency id="System.Threading.Tasks" version="4.0.11" />
        <dependency id="System.Threading.Thread" version="4.0.0" />
        <dependency id="System.Threading.ThreadPool" version="4.0.10" />
        <dependency id="System.Threading.Timer" version="4.0.1" />
        <dependency id="System.Buffers" version="4.0.0" />
        <dependency id="System.Numerics.Vectors" version="4.1.1" />
        <dependency id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" />
        <dependency id="System.Threading.Tasks.Extensions" version="4.0.0" />
        <dependency id="Libuv" version="1.9.0" />
        <dependency id="Microsoft.AspNetCore.Hosting" version="1.0.0" />
        <dependency id="Microsoft.Extensions.Logging.Abstractions" version="1.0.0" />
      </group>
    </dependencies>
  </metadata>
</package>
@TheRealPiotrP
Copy link

Some of the info in B will be required for e.g. AssemblyInfo.cs. How do we imagine these properties being shared with other targets?

@TheRealPiotrP
Copy link

👀

@rrelyea
Copy link

rrelyea commented Aug 4, 2016

@davkean has talked about some project system UI for this metadata, with assemblyinfo.cs having a new generated assemblyinfo.g.cs (or similar). I'd imagine that code generator would be one such target. David?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment