This is a simple Makefile that creates C# projects compatible with any OS / IDE / .NET core versions (that we know of).
-
Grab the
solution_name.zip
file from our release, -
Extract
solution_name.zip
, -
Open
solution_name/solution_name.sln
with your favorite IDE, -
Make sure you can compile and execute
Program.cs
. Normally, the program should display10 Hello from Class2
Please, open an issue if you cannot reproduce this behavior or if your IDE did not open correctly the project, or report to us if your OS / IDE / .Net version combination is not listed below.
- Some basic knowledge of Makefile,
- 7zip,
- A Unix system (which can be a Windows Subsystem for Linux),
- How to clone or download a repository.
Alternatively, you can simply clone this repository and have github's action produce the project for you, using our workflow.
To run the example,
-
(Download or clone this program.)
-
Run
make build/solution_name.zip
-
Look into the
build/
folder that was created for asolution_name.zip
file. -
Extract
solution_name.zip
, -
Open
solution_name/solution_name.sln
with your favorite IDE, -
Make sure you can compile and execute
Program.cs
. Normally, the program should display10 Hello from Class2
Please, open an issue if you cannot reproduce this behavior or if your IDE did not open correctly the project, or report to us if your OS / IDE / .Net version combination is not listed below.
To create a new project:
-
Create a folder in
src/
and name it after the solution (say,sol-xx
), -
Create a folder in
src/sol-xx
and name it after the project (say,proj-yy
), -
Create a
Program.cs
file (mandatory), and, possibly, one (or multiple) class files (called, for instance,Class1.cs
,Class2.cs
, etc., except that you can't actually use those names). -
Run
make build/sol-xx.zip
-
Check that the file
build/sol-xx.zip
was correctly created and can be opened with your IDE.
The makefile is actually very simple, it creates the .sln
, .csproj
and .cs
files to obtain this structure:
└───<Solution>
├── <Solution.sln>
└── <Project>
├── <Project>.csproj
├── Properties
│ └── AssemblyInfo.cs
├── Program.cs
└── <Class>.cs (Optional, can be repeated)
This is for very simple projects (such as the ones used for pedagogical purposes in this introduction to programming course), with portability in mind.
Despite the following source and discussions:
- https://learn.microsoft.com/en-us/visualstudio/ide/solutions-and-projects-in-visual-studio?view=vs-2022,
- https://stackoverflow.com/questions/2736260/programmatically-generate-visual-studio-solution,
- https://learn.microsoft.com/en-us/dotnet/core/porting/project-structure,
there are no specification (that we know of) for C# projects, hence the need for this type of approach.
We confirm that the solution created using this project work on the following:
OS | IDE | IDE Version | .Net Core SDK Version | .Net Core Runtime Version |
---|---|---|---|---|
Debian 12 | MonoDevelop | 7.8.4 | 8.0.10 | 8.0.0 |
Debian 12 | JetBrains Rider | 2023.3.2 | 8.0.10 | 8.0.0 |
MacOs Sonoma (14.1.1) | Visual Studio for Mac | 2022 | 7.0.308 | 7.0.11 |
Windows 11 | Visual Studio | 2022 | - | - |
Windows 10 Entreprise (22h2) | Visual Studio | Entreprise 2019 | 5.0.302 | 5.0.8 |
If your OS / IDE combination is not presented above, we would appreciate it if you could contact us or open a merge request adding your information.
The command dotnet --info
may give you the .Net Core SDK and .Net Core Runtime versions, if not please refer to https://learn.microsoft.com/en-us/dotnet/core/install/how-to-detect-installed-versions.