|
| 1 | +Updating Reference Assembly Versions |
| 2 | +=== |
| 3 | + |
| 4 | +# Creating a new Target Framework |
| 5 | +To create a new Target Framework assembly do the following. Note: this is written for creating `net7.0` but can be applied to any target framework by using the approriate moniker: |
| 6 | + |
| 7 | +First need to find the version of the Microsoft.NETCore.App.Ref to use. Navigate to the [NuPkg link](https://www.nuget.org/packages/Microsoft.NETCore.App.Ref) and find the latest version. In this case we'll be using 7.0.0-rc.1.22426.10. |
| 8 | + |
| 9 | +Create the directory `Basic.Reference.Assemblies.Net70` and add a project file with the following format: |
| 10 | + |
| 11 | +```xml |
| 12 | +<Project Sdk="Microsoft.NET.Sdk"> |
| 13 | + |
| 14 | + <PropertyGroup> |
| 15 | + <TargetFramework>netstandard2.0</TargetFramework> |
| 16 | + <IsPackable>true</IsPackable> |
| 17 | + </PropertyGroup> |
| 18 | + |
| 19 | + <ItemGroup> |
| 20 | + <PackageReference Include="Microsoft.NETCore.App.Ref" Version="7.0.0-rc.1.22426.10" IncludeAssets="none" PrivateAssets="all" GeneratePathProperty="true" /> |
| 21 | + </ItemGroup> |
| 22 | + |
| 23 | + <Import Project="Generated.targets" /> |
| 24 | +</Project> |
| 25 | +``` |
| 26 | + |
| 27 | +Run `dotnet restore` to ensure the NuPkg is downloaded to the machine. Update the `Generate.ps1` file to have an entry for the new target framework |
| 28 | + |
| 29 | +**Note**: the version on disk can differ from what is put in the csproj file. If `Generate.ps1` fails check to see if the version on disk was slightly different and just use that. |
| 30 | + |
| 31 | +```ps1 |
| 32 | +# Net70 |
| 33 | +$map = Get-Content "Net70" 'microsoft.netcore.app.ref\7.0.0-rc.2.22469.6\ref\net7.0' |
| 34 | +$targetDir = Join-Path $PSScriptRoot "..\Basic.Reference.Assemblies.Net70" |
| 35 | +$map.CodeContent | Out-File (Join-Path $targetDir "Generated.cs") -Encoding Utf8 |
| 36 | +$map.TargetsContent | Out-File (Join-Path $targetDir "Generated.targets") -Encoding Utf8 |
| 37 | +$map.CodeContent | Out-File (Join-Path $combinedDir "Generated.Net70.cs") -Encoding Utf8 |
| 38 | +$map.TargetsContent | Out-File (Join-Path $combinedDir "Generated.Net70.targets") -Encoding Utf8 |
| 39 | +``` |
| 40 | + |
| 41 | +Open the Basic.Reference.Assemblies.sln file in Visual Studio. Use `Add Existing Project` to include `Basic.Reference.Assemblies.Net70.csproj` in the solution. Then open `Basic.Reference.Assemblies.csproj` and ensure the new Generated targets are imported |
| 42 | + |
| 43 | +```xml |
| 44 | + <Import Project="Generated.Net70.targets" /> |
| 45 | +``` |
| 46 | + |
| 47 | +Open `publish.yml` and add an entry for the target framework |
| 48 | + |
| 49 | +```yml |
| 50 | + - name: Pack Net70 |
| 51 | + run: dotnet pack --no-build -p:IncludeSymbols=false -p:RepositoryCommit=${GITHUB_SHA} -p:PackageVersion="${{ github.event.inputs.version }}" -c Release Basic.Reference.Assemblies.Net70/Basic.Reference.Assemblies.Net70.csproj -o . |
| 52 | +``` |
| 53 | +
|
| 54 | +# Upgrading existing Target Framework |
| 55 | +To upgrade an existing target framework do the following: |
| 56 | +
|
| 57 | +1. Navigate to https://www.nuget.org/packages/Microsoft.NETCore.App.Ref and find the latest version for the target framework. For say `net6.0` that will be the latest version begining with `6.0`. |
| 58 | +2. Move to that version in the appropriate project file. For say `net6.0` that wil be Basic.Reference.Assemblies.Net60.csproj |
| 59 | +3. Move to that version in Generate.ps1 for the target framework |
| 60 | +4. Run `Scripts\Generate.ps1` |
| 61 | + |
0 commit comments