From 7c187c18b6e02fe2ff6d211bed220788ab933a19 Mon Sep 17 00:00:00 2001 From: Ido Flatow Date: Mon, 3 Mar 2025 20:01:07 +0200 Subject: [PATCH] Upgrade hello-world sample to .NET 8 (#2936) --- run/helloworld/Dockerfile | 6 +++--- run/helloworld/Program.cs | 2 +- run/helloworld/helloworld.csproj | 4 ++-- run/helloworld/runTests.ps1 | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 run/helloworld/runTests.ps1 diff --git a/run/helloworld/Dockerfile b/run/helloworld/Dockerfile index a21689d8ba2..2f04fe96e7d 100644 --- a/run/helloworld/Dockerfile +++ b/run/helloworld/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2022 Google Inc. +# Copyright 2025 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ # limitations under the License. # Use Microsoft's official build .NET image. -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env WORKDIR /app # Copy csproj and restore as distinct layers @@ -25,7 +25,7 @@ COPY . ./ RUN dotnet publish -c Release -o out # Build runtime image -FROM mcr.microsoft.com/dotnet/aspnet:6.0 +FROM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app COPY --from=build-env /app/out . diff --git a/run/helloworld/Program.cs b/run/helloworld/Program.cs index e8e35f60613..cb11da9cc3e 100644 --- a/run/helloworld/Program.cs +++ b/run/helloworld/Program.cs @@ -1,4 +1,4 @@ -// Copyright 2022 Google Inc. +// Copyright 2025 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/run/helloworld/helloworld.csproj b/run/helloworld/helloworld.csproj index e2b5ad1816a..13d81270429 100644 --- a/run/helloworld/helloworld.csproj +++ b/run/helloworld/helloworld.csproj @@ -1,9 +1,9 @@ - net6.0 + net8.0 enable enable - \ No newline at end of file + diff --git a/run/helloworld/runTests.ps1 b/run/helloworld/runTests.ps1 new file mode 100644 index 00000000000..c080966e078 --- /dev/null +++ b/run/helloworld/runTests.ps1 @@ -0,0 +1,16 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +dotnet restore --force +dotnet publish --no-restore -c Release -f net8.0 2>&1 | %{ "$_" }