Skip to content

Create targets and tasks for authoring a shared framework #2704

Closed
@natemcmaster

Description

@natemcmaster

There are 3 different shared frameworks built by .NET teams - NETCore.App, AspNetCore.App, and WindowsDesktop.App. We share similar requirements and similar code. I think we should commonize these into a shared package to reduce the maintenance burden of building shared frameworks 'the right way.'

Desired usage

Projects which need to author a framework can create two project files, one for the targeting pack and another for the runtime packs. Both projects use a custom MSBuild SDK, "Microsoft.NET.SharedFramework.Sdk" and set some well-known properties which will inform the custom SDK how to build a shared framework.

Requirements

  • Generate a shared framework (gather binaries into a single folder)
  • Generate a shared framework layout ($dotnet_root$/shared/$name$/$version$)
  • The SDK can generate the manifests which all shared frameworks are supposed to include
    • .deps.json
    • .runtimeconfig.json
    • PackageOverrides.txt
    • PlatformManifest.txt
  • The SDK can produce .nupkgs with the correct layout and content for
    • The ref pack
    • The runtime pack
  • The SDK can crossgen assemblies in the shared framework
    • By default, enabled only when Configuration == Release

Out of scope

  • Generalizing support for building msi/deb/rpm/zip/tgz installers and archives.
  • Generating the AppHost packages (out of scope for now)
  • FrameworkList.xml - spec for this still unclear

Project file API

Example usage for the runtime project

<Project Sdk="Microsoft.NET.SharedFramework.Sdk">
  <PropertyGroup>
     <!-- Required properties -->
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SharedFrameworkName>Microsoft.Banana.App</SharedFrameworkName>
    <PlatformPackageType>RuntimePack</PlatformPackageType>
    
    <!--  This will be the default, but be overridden by the project file. -->
    <PackageId>Microsoft.Banana.App.Runtime.$(RuntimeIdentifier)</PackageId>
  </PropertyGroup>
  
  <ItemGroup>
    <FrameworkReference Include="Microsoft.NETCore.App" RuntimeFrameworkVersion="3.0.0" />
    
    <ProjectReference Include="..\..\MyAssembly1\MyAssembly1.csproj" />
    <ProjectReference Include="..\..\MyAssembly2\MyAssembly2.csproj" />
    
    <NativeRuntimeAsset Include="linux-x64/libmydep.so" Condition=" '$(RuntimeIdentifier)' == 'linux-x64' " />
  </ItemGroup>
  
</Project>

Example usage for the targeting pack project

<Project Sdk="Microsoft.NET.SharedFramework.Sdk">
  <PropertyGroup>
     <!-- Required properties -->
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <SharedFrameworkName>Microsoft.Banana.App</SharedFrameworkName>
    <PlatformPackageType>TargetingPack</PlatformPackageType>
    
    <!--  This will be the default, but be overridden by the project file. -->
    <PackageId>Microsoft.Banana.App.Ref</PackageId>
  </PropertyGroup>
  
  <ItemGroup>
    <ProjectReference Include="..\..\MyAssembly1\MyAssembly1.csproj" />
    <ProjectReference Include="..\..\MyAssembly2\MyAssembly2.csproj" />
    
    <!--  Optimization for assemblies that are provided in both a targeting pack and an OOB NuGet package.  -->
    <ProvidesPackage Include="MyAssembly1" Version="1.0.0" />
  </ItemGroup>
</Project>

cc @ericstj @dagood

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions