Skip to content

Commit 2bcb4e8

Browse files
Added a new doc for adding projects to the repo (#41949)
1 parent 4094430 commit 2bcb4e8

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

docs/AddingNewProjects.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Adding New Projects To The Repo
2+
3+
Sample PR of final result: https://github.com/dotnet/aspnetcore/pull/41945
4+
5+
## Creating a new project
6+
1. Create a new folder that will house your `.csproj` and other project-related files.
7+
2. (EXTREMELY IMPORTANT) Inside this new folder, make a new folder for the source files of your project. For regular functionality-adding project this will be called `src`. However, if you are adding a different kind of project, it will be called something more applicable (ex. `test/` for a test project).
8+
3. Open the `.slnf` you want to add your project to in VS (preferably via the `startvs.cmd` script located in the same folder as the `.slnf`). Then add a new `Solution Folder` in the new folder with the same name and location as the actual folder created in the first step.
9+
4. Create the project via the VS `Add` menu (select the folder -> right click -> Add -> New Project... -> follow the wizard).
10+
11+
**Note:** (Only applicable to `src/` projects) Depending on what kind of project you are creating, VS will create different files in your project. You might also want to add the following files:
12+
- `PublicAPI.Shipped.txt`
13+
- Lists publically visible APIs that are exported from your final compiled `.dll`.
14+
- This only lists APIs that have already been shipped to customers and cannot be changed.
15+
- There is an empty template at `eng/PublicAPI.empty.txt` for your reference. You can copy and rename the file to add it to your project. Make sure the name is exactly as shown above.
16+
- `PublicAPI.UnShipped.txt`
17+
- Lists publicly visible APIs that are exported from your final compiled `.dll`. If this is not configured properly, you will get build errors. VS will warn you though with green squiggly lines. If you see these squiggly lines, open the VS Quick Actions (CTRL + '.') and select the option to and it to the public API.
18+
- This only lists APIs that have NOT already been shipped to customers. So, these can still change.
19+
- There is an empty template at `eng/PublicAPI.empty.txt` for your reference. You can copy and rename the file to add it to your project. Make sure the name is exactly as shown above.
20+
- You can expose internals via `@(InternalsVisibleTo)` items in your `.csproj`.
21+
```XML
22+
<ItemGroup>
23+
<InternalsVisibleTo Include="Microsoft.AspNetCore.My.TestProject" />
24+
```
25+
26+
27+
## Adding to the rest of the repo
28+
1. VS should have already registered your `.csproj` in the corresponding solution ([`.sln`](https://github.com/dotnet/aspnetcore/blob/586ccc8c895862b65645c4b0f979db1eecd29626/AspNetCore.sln)) and solution filter ([`.slnf`](https://github.com/dotnet/aspnetcore/blob/586ccc8c895862b65645c4b0f979db1eecd29626/src/Middleware/Middleware.slnf#L107-L109)) files.
29+
- If VS has not already modified these files, open the `.slnf` you want to add the project to. Create a solution folder for your project if doesn't exist already. Then right click solution folder -> Add -> Existing Project... -> follow the wizard.
30+
2. Run the `eng/scripts/GenerateProjectList.ps1` file to regenerate a number of `eng/*.props` files e.g. ProjectReferences.props.
31+
32+
**Note:** If you are adding a new project to the root `src` directory, you will also need to add a reference in both of the `DotNetProjects` lists of the `eng/Build.props` file. The first list (the one with condition `'$(BuildMainlyReferenceProviders)' != 'true'"`) has items in the format of:
33+
```XML
34+
<DotNetProjects Include="
35+
$(RepoRoot)src\[YOUR FOLDER]\**\*.csproj;
36+
...
37+
```
38+
while the second (the one with condition `'$(BuildMainlyReferenceProviders)' == 'true'"`) has them in the format of (note the second `src`):
39+
```XML
40+
<DotNetProjects Include="
41+
$(RepoRoot)src\[YOUR FOLDER]\**\src\*.csproj;
42+
...
43+
```
44+
45+
## (OPTIONAL) Including your project in SharedFx
46+
1. Add the following line to the `.csproj`'s `PropertyGroup` to include your project in the SharedFx API:
47+
```XML
48+
<IsAspNetCoreApp>true</IsAspNetCoreApp>
49+
```
50+
2. Re-run the `eng/scripts/GenerateProjectList.ps1` to add your project to the `eng/SharedFramework.Local.props` file and, if applicable, the `eng/TrimmableProjects.props` file.
51+
3. Add your project name to the lists in `src\Framework\test\TestData.cs`. This is not strictly necessary for the project to work but there is a test on CI that will fail if this is not done. Make sure to include your project in a way that maintains alphabetical ordering.
52+
53+
## Manually saving solution and solution filter files
54+
VS is pretty good at keeping the files up to date and organized correctly. It will also prompt you if it finds an error and, in most cases, offer a solution to fix the issue. Sometimes just saving the file will trigger VS to resolve any issues automatically. However, if you would like to add a new solution filter file or update one manually you can find a tutorial link [here](https://docs.microsoft.com/en-us/visualstudio/ide/filtered-solutions?view=vs-2022).

docs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ The table below outlines the different docs in this folder and what they are hel
2626
| [Triage process](TriageProcess.md)| Overview of the issue triage process used in the repo | Anyone looking to understand the triage process on the repo |
2727
| [Updating Major Version & TFM](UpdatingMajorVersionAndTFM.md)| Instructions for updating the repo branding & TFM in preparation for a new major release | Repo developers who want to know more about our branding & release process |
2828
| [Assembly trimming guide](Trimming.md)| Guidance on adding trimming support to an ASP.NET Core assembly | Repo developers who want to help add support for trimming to ASP.NET Core |
29+
| [Adding new Projects to the Repo](AddingNewProjects.md) | Outlines the process of adding new projects (i.e. `.csproj` files) to the repo | Anyone who finds themselves trying to add a new project and including it in the build.

0 commit comments

Comments
 (0)