A powerful Python script that automates the creation of C# console applications with customizable templates and framework selection.
- Interactive Project Creation - Simple command-line interface for creating C# projects
- Framework Selection - Automatically detects and allows selection from installed .NET SDKs
- Template-Based Architecture - Clean separation of templates for easy customization
- Multi-Language Support - Originally created in Vietnamese, now fully in English
- Error Handling - Robust error handling with user-friendly messages
- Template Customization - Easy to modify project structure and content
- Python 3.6 or higher
- .NET SDK (any version - the tool will detect installed versions)
- Terminal/Command prompt access
- Clone or download the project files
- Ensure
create_csharp_project.pyis executable:chmod +x create_csharp_project.py
- Verify .NET SDK is installed:
dotnet --version
Run the script from the terminal:
python3 create_csharp_project.py- Enter Project Name: Provide a name for your new C# project
- Select Framework: Choose from detected .NET SDKs or use default (net7.0)
- Project Creation: The tool creates a complete project structure
$ python3 create_csharp_project.py
🚀 Create Simple C# Project
========================================
Enter C# project name: MyAwesomeApp
📋 Available .NET Framework Versions:
1. net6.0
2. net7.0
3. net8.0
Select framework (1-3) or press Enter for default (net7.0): 2
🎯 Selected framework: net7.0
📁 Created directory: MyAwesomeApp
✅ Created file: Program.cs
✅ Created file: README.md
✅ Created file: MyAwesomeApp.csproj
🎉 Project 'MyAwesomeApp' has been created successfully!
📂 Project directory: /path/to/MyAwesomeApp
To run the project:
cd MyAwesomeApp
dotnet run
✅ Complete! Project is ready to use.After running the tool, your project will have this structure:
MyProject/
├── Program.cs # Main C# source file
├── README.md # Project documentation
└── MyProject.csproj # .NET project file
using System;
namespace MyProject
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World from MyProject!");
}
}
}<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>MyProject</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>The tool uses template files located in the templates/ directory:
templates/Program.cs.template- Main source code templatetemplates/README.md.template- Documentation templatetemplates/project.csproj.template- Project file template
{PROJECT_NAME}- Replaced with the user-provided project name{FRAMEWORK_VERSION}- Replaced with selected .NET framework version
To customize generated files, edit the template files:
- Modify
templates/Program.cs.templatefor different starter code - Update
templates/README.md.templatefor custom documentation - Edit
templates/project.csproj.templatefor different project settings
The tool automatically detects installed .NET SDKs using:
dotnet --list-sdksDetected frameworks are presented as numbered options during project creation.
If no framework is selected (user presses Enter), the tool defaults to net7.0.
The tool includes comprehensive error handling for:
- Missing project names
- Template file errors
- Directory creation failures
- .NET SDK detection issues
Issue: No .NET SDKs detected
⚠️ No .NET SDKs detected, using default framework (net7.0)
Solution: Install a .NET SDK or verify dotnet command is available in PATH
Issue: Template files not found
❌ Error loading template templates/Program.cs.template: [Errno 2] No such file or directory
Solution: Ensure the templates/ directory exists and contains the required template files
Issue: Permission denied creating directory
❌ Error creating directory: [Errno 13] Permission denied: 'ProjectName'
Solution: Run the script from a directory where you have write permissions
If you encounter issues:
- Check that all requirements are met
- Verify file permissions
- Ensure .NET SDK is properly installed
- Check the templates directory exists
To contribute to this project:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
- Created with Cline AI Assistant
- Supports multiple .NET framework versions
- Template-based architecture for maintainability
Happy Coding! 🎉