This Python script automates the creation of a .NET MVC project alongside a Vite React project, and includes a build.py
script for building and running both projects. Follow the steps below to use the script effectively.
-
Python Installation: Ensure Python is installed on your system. You can download Python from python.org.
-
Node.js and npm: Ensure Node.js and npm are installed on your system. You can download them from nodejs.org.
-
Dotnet CLI: Ensure dotnet CLI is installed on your system. You can download it from dotnet.microsoft.com.
-
Clone or Download the Script: Obtain the
REACT.MVC.NET.py
script from your repository or download it from the source. -
Open Terminal or Command Prompt: Navigate to the directory containing
REACT.MVC.NET.py
. -
Execute the Script: Run the script by entering the following command:
python REACT.MVC.NET.py
-
Follow the Prompts:
- Enter the desired project name when prompted.
- The script will then proceed to:
- Create a
.NET MVC
project namedprojectname.MVC
. - Create a
Vite React
project namedprojectname.REACT
. - Generate a
build.py
script for building and running the projects.
- Create a
The REACT.MVC.NET.py
script automates the following tasks:
-
Project Initialization: Uses
dotnet new mvc
command to create a .NET MVC project namedprojectname.MVC
. -
Solution File: Creates a solution file (
projectname.MVC.sln
) and adds the MVC project to it usingdotnet new sln
anddotnet sln add
commands. -
File Management: Removes unnecessary
Program.cs
andwwwroot
directory if it exists, then recreateswwwroot
to prepare for the React build.
-
Project Initialization: Uses
npm init vite@latest
command to create a Vite React project namedprojectname.REACT
with the React template. -
Dependencies Installation: Installs necessary dependencies and builds the Vite React project using
npm install
andnpm run build
. -
Build Integration: Copies the built React project (
dist
directory) into the.NET MVC
project'swwwroot
directory.
-
Python Script: Generates a
build.py
script that automates the build and deployment process of both projects. -
Build Automation: Provides functions to change directory, build the Vite React project, and copy the build output to the
.NET MVC
project'swwwroot
.
The build.py
script facilitates building and running both projects (projectname.MVC
and projectname.REACT
):
-
Navigate to Project Directory: Open a terminal and navigate to the directory containing
build.py
. -
Execute the Script: Run the script by entering the following command:
python build.py
-
Automated Tasks: The script automates:
- Changing directory to the React project (
projectname.REACT
). - Building the Vite React project.
- Copying the built React files (
dist
directory) to the.NET MVC
project'swwwroot
directory.
- Changing directory to the React project (
-
Error Handling: If any errors occur during script execution, detailed error messages will be displayed in the terminal.
-
Customization: Feel free to modify
REACT.MVC.NET.py
orbuild.py
scripts to suit additional project requirements or customization needs.
This README provides a comprehensive guide on using REACT.MVC.NET.py
to automate the creation and integration of a .NET MVC project with a Vite React project. Ensure all prerequisites are met and follow the outlined steps for seamless project creation, integration, and deployment. Adjustments can be made based on specific project requirements or preferences.