Skip to content

Commit 1a56385

Browse files
committed
Update README and fix DualProjects props options
1 parent 287339a commit 1a56385

3 files changed

Lines changed: 105 additions & 13 deletions

File tree

README.md

Lines changed: 101 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ Some useful scripts.
44

55
## dotnet-new/dual-projects.ps1
66

7+
<<<<<<< HEAD
78
Allows you to create a project, using any template available with `dotnet new`, and it associated xunit test project.
9+
=======
10+
Allows you to create a project of any type (possible with `dotnet new`) and its associated test project (using `xunit`).
11+
Optionally, you can also create a functional tests project which automatically import `Microsoft.AspNetCore.App` and `Microsoft.AspNetCore.Mvc.Testing`.
12+
13+
> > > > > > > Update README and fix DualProjects props options
814
915
The project structure is as follow:
1016

@@ -14,10 +20,12 @@ src
1420
{project name}
1521
test
1622
{project name}.Tests
23+
(optional){project name}.FunctionalTests
1724
(optional){solution name}.sln
1825
```
1926

2027
### How to install from source code
28+
2129
From the source code directory, execute the following command:
2230

2331
To install it locally, using the source:
@@ -31,6 +39,7 @@ Import-Module F:\Repos\ForEvolve.Scripts\dotnet-new\dual-projects\dual-projects.
3139
```
3240

3341
### How to install from MyGet
42+
3443
You can also use my published version, on MyGet, by executing the following commands:
3544

3645
Register my NuGet feed as `ForEvolveFeed`:
@@ -64,20 +73,25 @@ You may need update your execution policy, with `Set-ExecutionPolicy`, to be abl
6473
Set-ExecutionPolicy Unrestricted
6574
```
6675

67-
*You need to run PowerShell in admin mode to execute that command.*
76+
_You need to run PowerShell in admin mode to execute that command._
6877

69-
### Parameters
78+
### `Add-DualProjects` function
7079

71-
| Parameter | Alias | Switch? | Required | Default Value | Description |
72-
| ------------------ | ------------- | ------- | -------- | ------------- | -------------------------------------------------------------------------------- |
73-
| `-projectName` | `-p` | No | Yes | | The name of the project that you want to create, for exmaple: `SomeCoolProject`. |
74-
| `-projectTemplate` | `-t` | No | No | `web` | The `dotnet new` template to use for the main project. |
75-
| `-createSolution` | `-create-sln` | Yes | No | `$false` | Specify if you want to create a solution. |
76-
| `-solutionName` | `-s` | No | No | | The name of the solution to create if it differs from the project name. You must include the `.sln` extension; example: `My.sln`. |
77-
| `-mkdir` | | No | No | `$true` | Specify if you want to make a new directoy for the solution. |
78-
| `-noBuild` | `-no-build` | Yes | No | | If specified, `dotnet build` will not be run after the projects creation. |
80+
#### Parameters
7981

80-
### How to use
82+
| Parameter | Alias | Switch? | Required | Version | Default Value | Description |
83+
| --------------------------------- | ------------------------- | ------- | -------- | ------- | ------------- | ------------------------------------------------------------------------------------------------- |
84+
| `-projectName` | `-p` | No | Yes | 1.0.0 | | The name of the project that you want to create, for exmaple: `SomeCoolProject`. |
85+
| `-projectTemplate` | `-t` | No | No | 1.0.0 | `web` | The `dotnet new` template to use for the main project. |
86+
| `-createSolution` | `-create-sln` | Yes | No | 1.0.0 | `$false` | Specify if you want to create a solution. |
87+
| `-solutionName` | `-s` | No | No | 1.0.0 | | The name of the solution to create if it differs from the project name. |
88+
| `-mkdir` | | No | No | 1.0.0 | `$true` | Specify if you want to make a new directoy for the solution. |
89+
| `-noBuild` | `-no-build` | Yes | No | 1.0.0 | | If specified, `dotnet build` will not run after the projects creation. |
90+
| `-addFunctionalTests` | `-add-functional-tests` | Yes | No | 1.1.0 | | If specified, `Add-FunctionalTests` will be called to add a function tests project. |
91+
| `-customTestsPropsFile` | `-tests-props` | No | No | 1.1.0 | `$null` | Allow specifying a `.props` file that will be imported at the top of the unit test project. |
92+
| `-customFunctionalTestsPropsFile` | `-functional-tests-props` | No | No | 1.1.0 | `$null` | Allow specifying a `.props` file that will be imported at the top of the functional test project. |
93+
94+
#### How to use
8195

8296
How to create a project and a test project (named `SomeCoolProject`) in an existing solution:
8397

@@ -115,8 +129,72 @@ To tell the script not to build the solution, you can specify `-noBuild` or `-no
115129
Add-DualProjects -p SomeCoolProject -t mvc -s some-solution.sln -mkdir $false -no-build -create-sln
116130
```
117131

132+
<<<<<<< HEAD
133+
118134
## Other info (notes to self)
119135

136+
=======
137+
How to create a project named `SomeCoolProject`, a unit tests project, and a functional tests project in the default, existing, solution:
138+
139+
```powershell
140+
Add-DualProjects -projectName SomeCoolProject -add-functional-tests
141+
```
142+
143+
How to create a project named `SomeCoolProject`, a unit tests project, and a functional tests project in the default, existing, solution with each test project importing its own `props` file.
144+
This command also includes the `-no-build` flag which can become handy when `GenerateDocumentationFile` is set to `true` and `TreatWarningsAsErrors` is also set to `true` (in a `Directory.Build.props` file for example).
145+
146+
```powershell
147+
Add-DualProjects -projectName SomeCoolProject -add-functional-tests -functional-tests-props ..\FunctionalTests.Build.props -customTestsPropsFile ..\UnitTests.Build.props -no-build
148+
```
149+
150+
### `Add-FunctionalTests` function
151+
152+
#### Parameters
153+
154+
| Parameter | Alias | Switch? | Required | Version | Default Value | Description |
155+
| ------------------ | ----------- | ------- | -------- | ------- | ------------- | ------------------------------------------------------------------------------------------------------------ |
156+
| `-projectName` | `-p` | No | Yes | 1.1.0 | | The name of the project that you want to create, for exmaple: `SomeCoolProject`. |
157+
| `-solutionName` | `-s` | No | No | 1.1.0 | | The name of the solution to add your functional tests project to if there is more than one in the directory. |
158+
| `-noBuild` | `-no-build` | Yes | No | 1.1.0 | | If specified, `dotnet build` will not run after the projects creation. |
159+
| `-customPropsFile` | `-props` | No | No | 1.1.0 | `$null` | Allow specifying a `.props` file that will be imported at the top of the functional test project. |
160+
161+
#### How to use
162+
163+
How to create a functional tests project for the project `SomeCoolProject`:
164+
165+
```powershell
166+
Add-FunctionalTests -p SomeCoolProject
167+
```
168+
169+
> This will create a xunit project into `test/SomeCoolProject.FunctionalTests` linked to `src/SomeCoolProject`.
170+
171+
How to create a functional tests project for the project `SomeCoolProject` and include a `props` file located into `test/FunctionalTests.Build.props`:
172+
173+
```powershell
174+
Add-FunctionalTests -p SomeCoolProject -props ..\FunctionalTests.Build.props
175+
```
176+
177+
> This will add `<Import Project="..\FunctionalTests.Build.props" />` at the top of the project file ( under `<Project Sdk="Microsoft.NET.Sdk.Web">`).
178+
179+
## Other info
180+
181+
Use a custom MyGet feed:
182+
183+
```
184+
Import-Module PowerShellGet
185+
$PSGalleryPublishUri = 'https://www.myget.org/F/forevolve/api/v2/package'
186+
$PSGallerySourceUri = 'https://www.myget.org/F/forevolve/api/v2'
187+
Register-PSRepository -Name MyGetFeed -SourceLocation $PSGallerySourceUri -PublishLocation $PSGalleryPublishUri
188+
```
189+
190+
Install the module from that custom MyGet feed:
191+
192+
```
193+
Install-Module -Name "dual-projects" -RequiredVersion "1.0.0" -Repository MyGetFeed -Scope CurrentUser
194+
```
195+
196+
> > > > > > > Update README and fix DualProjects props options
197+
120198
Publish to that custom MyGet feed:
121199

122200
```
@@ -127,3 +205,15 @@ Publish-Module -Path dotnet-new -NuGetApiKey $APIKey -Repository ForEvolveFeed -
127205
Read feeds list: `Get-PSRepository`
128206

129207
Create a module manifest: `New-ModuleManifest -Path dual-projects.psd1`
208+
209+
# Release Notes
210+
211+
## 1.1.0
212+
213+
- Add the `Add-FunctionalTests` function.
214+
- Add functional tests options to the `Add-DualProjects` function (which now act more like "add three projects" than "add two projects").
215+
- Unit tests and fucntional tests projects now adds the right `RootNamespace` in their `csproj` file.
216+
217+
## 1.0.0
218+
219+
- Initial release of the `Add-DualProjects` function.
0 Bytes
Binary file not shown.

dotnet-new/dual-projects/dual-projects.psm1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ function Add-DualProjects {
9696
Write-Debug "mkdir: $mkdir"
9797
Write-Debug "noBuild: $noBuild"
9898
Write-Debug "addFunctionalTests: $addFunctionalTests"
99+
Write-Debug "customTestsPropsFile: $customTestsPropsFile"
100+
Write-Debug "customFunctionalTestsPropsFile: $customFunctionalTestsPropsFile"
99101

100102
if ($createSolution) {
101103
Add-Solution $solutionName $mkdir $projectName
@@ -113,11 +115,11 @@ function Add-DualProjects {
113115
ReferenceSourceFromTest $srcProjectPath $testProjectPath
114116

115117
# Update the RootNamespace to the test project
116-
UpdateRootNamespace $projectName $testProjectPath
118+
UpdateRootNamespace $projectName $testProjectPath $customTestsPropsFile
117119

118120
# Create a functional test project
119121
if ($addFunctionalTests) {
120-
Add-FunctionalTests $projectName $solutionName -no-build
122+
Add-FunctionalTests $projectName $solutionName -no-build -props $customFunctionalTestsPropsFile
121123
}
122124

123125
# Execute post-creation actions

0 commit comments

Comments
 (0)