Skip to content

Commit 5bae169

Browse files
authored
Merge pull request #358 from codecrafters-io/andy/update-csharp
CC-2076: Upgrade C# to dotnet 10
2 parents ecc5b8a + 4351947 commit 5bae169

66 files changed

Lines changed: 240 additions & 210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiled_starters/csharp/.codecrafters/compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
dotnet build --configuration Release --output /tmp/codecrafters-build-csharp codecrafters-shell.csproj
11+
dotnet build --configuration Release --output /tmp/codecrafters-build-csharp CodeCrafters.Shell.csproj

compiled_starters/csharp/.codecrafters/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
exec /tmp/codecrafters-build-csharp/codecrafters-shell "$@"
11+
exec /tmp/codecrafters-build-csharp/CodeCrafters.Shell "$@"

compiled_starters/csharp/codecrafters-shell.csproj renamed to compiled_starters/csharp/CodeCrafters.Shell.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net9.0</TargetFramework>
6-
<RootNamespace>codecrafters-shell</RootNamespace>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<RootNamespace>CodeCrafters.Shell</RootNamespace>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99
</PropertyGroup>

solutions/csharp/02-cz2/code/codecrafters-shell.sln renamed to compiled_starters/csharp/CodeCrafters.Shell.sln

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 25.0.1700.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "codecrafters-shell", "codecrafters-shell.csproj", "{29097840-2370-4610-9275-010B39679800}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCrafters.Shell", "CodeCrafters.Shell.csproj", "{29097840-4F82-488B-ABD7-000F8C969040}"
7+
78
EndProject
89
Global
910
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1011
Debug|Any CPU = Debug|Any CPU
1112
Release|Any CPU = Release|Any CPU
1213
EndGlobalSection
1314
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{29097840-2370-4610-9275-010B39679800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{29097840-2370-4610-9275-010B39679800}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{29097840-2370-4610-9275-010B39679800}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{29097840-2370-4610-9275-010B39679800}.Release|Any CPU.Build.0 = Release|Any CPU
15+
{29097840-4F82-488B-ABD7-000F8C969040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{29097840-4F82-488B-ABD7-000F8C969040}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{29097840-4F82-488B-ABD7-000F8C969040}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{29097840-4F82-488B-ABD7-000F8C969040}.Release|Any CPU.Build.0 = Release|Any CPU
1819
EndGlobalSection
1920
GlobalSection(SolutionProperties) = preSolution
2021
HideSolutionNode = FALSE
2122
EndGlobalSection
2223
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {472BAEA1-4236-4421-9124-01A544818715}
24+
SolutionGuid = {472BAEA1-89E4-4110-92A0-001AF78D2B01}
2425
EndGlobalSection
2526
EndGlobal

compiled_starters/csharp/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ REPLs, builtin commands, and more.
1313

1414
# Passing the first stage
1515

16-
The entry point for your `shell` implementation is in `src/main.cs`. Study and
17-
uncomment the relevant code, then run the command below to execute the tests on
18-
our servers:
16+
The entry point for your `shell` implementation is in `src/Program.cs`. Study
17+
and uncomment the relevant code, then run the command below to execute the tests
18+
on our servers:
1919

2020
```sh
2121
codecrafters submit
@@ -27,8 +27,8 @@ Time to move on to the next stage!
2727

2828
Note: This section is for stages 2 and beyond.
2929

30-
1. Ensure you have `dotnet (9.0)` installed locally
30+
1. Ensure you have `dotnet (10.0)` installed locally
3131
1. Run `./your_program.sh` to run your program, which is implemented in
32-
`src/main.cs`.
32+
`src/Program.cs`.
3333
1. Run `codecrafters submit` to submit your solution to CodeCrafters. Test
3434
output will be streamed to your terminal.

compiled_starters/csharp/codecrafters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ debug: false
77
# Use this to change the C# version used to run your code
88
# on Codecrafters.
99
#
10-
# Available versions: dotnet-9.0
11-
buildpack: dotnet-9.0
10+
# Available versions: dotnet-10.0
11+
buildpack: dotnet-10.0

compiled_starters/csharp/your_program.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ set -e # Exit early if any commands fail
1414
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
1515
(
1616
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
17-
dotnet build --configuration Release --output /tmp/codecrafters-build-csharp codecrafters-shell.csproj
17+
dotnet build --configuration Release --output /tmp/codecrafters-build-csharp CodeCrafters.Shell.csproj
1818
)
1919

2020
# Copied from .codecrafters/run.sh
2121
#
2222
# - Edit this to change how your program runs locally
2323
# - Edit .codecrafters/run.sh to change how your program runs remotely
24-
exec /tmp/codecrafters-build-csharp/codecrafters-shell "$@"
24+
exec /tmp/codecrafters-build-csharp/CodeCrafters.Shell "$@"

dockerfiles/dotnet-10.0.Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1.7-labs
2+
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine
3+
4+
RUN apk add --no-cache --upgrade 'bash>=5.3'
5+
6+
WORKDIR /app
7+
8+
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
9+
COPY --exclude=.git --exclude=README.md . /app
10+
11+
# This saves nuget packages to ~/.nuget
12+
RUN dotnet build --configuration Release .
13+
14+
# This seems to cause a caching issue with the dotnet build command, where old contents are used
15+
# https://github.com/codecrafters-io/build-your-own-redis/pull/203
16+
# TODO: See if this needs to be brought back?
17+
# RUN rm -rf /app/obj
18+
# RUN rm -rf /app/bin
19+
20+
RUN echo "cd \${CODECRAFTERS_REPOSITORY_DIR} && dotnet build --configuration Release ." > /codecrafters-precompile.sh
21+
RUN chmod +x /codecrafters-precompile.sh
22+
23+
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="CodeCrafters.Shell.csproj,CodeCrafters.Shell.sln"

solutions/csharp/01-oo8/code/.codecrafters/compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
dotnet build --configuration Release --output /tmp/codecrafters-build-csharp codecrafters-shell.csproj
11+
dotnet build --configuration Release --output /tmp/codecrafters-build-csharp CodeCrafters.Shell.csproj

0 commit comments

Comments
 (0)