Skip to content

Commit

Permalink
Multi-targeting with .NET 8.
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Oct 13, 2023
1 parent 678602e commit bb0d294
Show file tree
Hide file tree
Showing 74 changed files with 471 additions and 451 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ file_header_template = Copyright (c) David Pine. All rights reserved.\nLicensed
indent_size = 4
tab_width = 4
trim_trailing_whitespace = true
end_of_line = lf

###############################
# .NET Coding Conventions #
Expand Down
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
10 changes: 6 additions & 4 deletions .github/workflows/build-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Setup .NET 7.0
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
dotnet-quality: preview

- name: Restore dependencies for ${{ matrix.project }}
run: |
Expand All @@ -59,10 +60,11 @@ jobs:
steps:
- uses: actions/checkout@main

- name: Setup .NET 7.0
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
dotnet-quality: preview

- name: Run tests
run: |
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
dotnet-quality: preview
- name: Test
run: dotnet test --filter "Category!=EndToEnd" --configuration Release

Expand Down Expand Up @@ -65,7 +66,8 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
dotnet-quality: preview

- name: Restore dependencies for ${{ matrix.project }}
run: |
Expand Down
75 changes: 38 additions & 37 deletions .github/workflows/publish-to-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
name: publish demo
on:
push:
branches: [ main ]
name: publish demo
on:
push:
branches: [ main ]
paths:
- 'samples/**'
- 'samples/**'
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: true
default: 'Manual run'
jobs:
deploy-to-github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
default: 'Manual run'
jobs:
deploy-to-github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: 'Print manual run reason'
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
- name: Publish .NET Core Project
run: dotnet publish samples/Blazor.ExampleConsumer/Blazor.ExampleConsumer.csproj -c Release -o release --nologo

# Changes the base-tag in index.html from '/' to '/blazorators' to match GitHub Pages repository subdirectory
- name: Change base-tag in index.html from / to /blazorators
run: sed -i 's/<base href="\/" \/>/<base href="\/blazorators\/" \/>/g' release/wwwroot/index.html

# Copy index.html to 404.html to serve the same file when a file is not found
- name: copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html

# Add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project.
# Allow files and folders starting with an underscore
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll

- name: Commit wwwroot to GitHub Pages
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 8.0.x
dotnet-quality: preview
- name: Publish .NET Core Project
run: dotnet publish samples/Blazor.ExampleConsumer/Blazor.ExampleConsumer.csproj -c Release -o release --nologo

# Changes the base-tag in index.html from '/' to '/blazorators' to match GitHub Pages repository subdirectory
- name: Change base-tag in index.html from / to /blazorators
run: sed -i 's/<base href="\/" \/>/<base href="\/blazorators\/" \/>/g' release/wwwroot/index.html

# Copy index.html to 404.html to serve the same file when a file is not found
- name: copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html

# Add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project.
# Allow files and folders starting with an underscore
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll

- name: Commit wwwroot to GitHub Pages
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: release/wwwroot
72 changes: 44 additions & 28 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
<Project>
<PropertyGroup>
<_ParentDirectoryBuildPropsPath Condition="'$(_DirectoryBuildPropsFile)' != ''">$([System.IO.Path]::Combine('..', '$(_DirectoryBuildPropsFile)'))</_ParentDirectoryBuildPropsPath>
</PropertyGroup>

<Import Project="$(_ParentDirectoryBuildPropsPath)" Condition="Exists('$(_ParentDirectoryBuildPropsPath)')"/>

<PropertyGroup>
<WarningLevel>3</WarningLevel>
<AnalysisLevel>preview</AnalysisLevel>
<Features>strict</Features>
</PropertyGroup>

<PropertyGroup>
<DefaultTargetFrameworks>net7.0</DefaultTargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
<SourceLinkCreate>true</SourceLinkCreate>
<SourceLinkOriginUrl>https://github.com/IEvangelist/azure-cosmos-dotnet-repository</SourceLinkOriginUrl>
</PropertyGroup>
<PropertyGroup>
<_ParentDirectoryBuildPropsPath Condition="'$(_DirectoryBuildPropsFile)' != ''">$([System.IO.Path]::Combine('..', '$(_DirectoryBuildPropsFile)'))</_ParentDirectoryBuildPropsPath>
</PropertyGroup>

<Import Project="$(_ParentDirectoryBuildPropsPath)" Condition="Exists('$(_ParentDirectoryBuildPropsPath)')"/>

<PropertyGroup>
<WarningLevel>3</WarningLevel>
<AnalysisLevel>preview</AnalysisLevel>
<Features>strict</Features>
</PropertyGroup>

<PropertyGroup>
<DefaultTargetFrameworks>net7.0;net8.0</DefaultTargetFrameworks>
</PropertyGroup>

<!-- .NET 7 package reference versions -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net7.0'">
<DependencyInjectionVersion>7.0.0</DependencyInjectionVersion>
<PrimitivesVersion>7.0.0</PrimitivesVersion>
<JSInteropVersion>7.0.12</JSInteropVersion>
<ComponentsWebVersion>7.0.12</ComponentsWebVersion>
</PropertyGroup>

<!-- .NET 8 package reference versions -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<DependencyInjectionVersion>8.0.0-rc.2.23479.6</DependencyInjectionVersion>
<PrimitivesVersion>8.0.0-rc.2.23479.6</PrimitivesVersion>
<JSInteropVersion>8.0.0-rc.2.23480.2</JSInteropVersion>
<ComponentsWebVersion>8.0.0-rc.2.23480.2</ComponentsWebVersion>
</PropertyGroup>

<PropertyGroup>
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
<SourceLinkCreate>true</SourceLinkCreate>
<SourceLinkOriginUrl>https://github.com/IEvangelist/azure-cosmos-dotnet-repository</SourceLinkOriginUrl>
</PropertyGroup>
</Project>
7 changes: 4 additions & 3 deletions samples/Blazor.ExampleConsumer/Blazor.ExampleConsumer.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-rc.2.23480.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions samples/Blazor.ExampleConsumer/Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@using System.Runtime.InteropServices
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<main>
<div class="top-row px-4 text-muted">
Powered by @RuntimeInformation.FrameworkDescription
</div>

<article class="content px-4 col-xl-8">
@Body
</article>

</main>
</div>

0 comments on commit bb0d294

Please sign in to comment.