Skip to content

Commit

Permalink
build(sln): fix and document Repository-Setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
seangwright committed Oct 23, 2024
1 parent d790c44 commit c6039ff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 41 deletions.
19 changes: 0 additions & 19 deletions Kentico.Xperience.RepoTemplate.sln

This file was deleted.

7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## ---Template info---

---Run the `Repository-Setup.ps1` in the root of this repository, specifying the `ProjectName` for the new project
---ex: `.\Repository-Setup.ps1 -ProjectName Kentico.Xperience.CoolProject`

---This section contains general information about the repository template and is to be deleted before submitting a pull request with the final documentation.---

---Lines enclosed by three dashes (like this one) are placeholders and comments to be replaced with specific information or deleted completely.---
Expand Down Expand Up @@ -57,11 +60,11 @@ dotnet add package <library nuget package name>

---Minimal steps to get started with the library. Support the steps with helpful screenshots.---

---You can completely omit this section if the setup is complicated and cannot be realistically condensed into a few steps. Instead, describe everything in detail in *Usage-Guide.md*.---
---You can completely omit this section if the setup is complicated and cannot be realistically condensed into a few steps. Instead, describe everything in detail in _Usage-Guide.md_.---

## Full Instructions

---Add the full instructions, guidance, and tips to the *Usage-Guide.md* file---
---Add the full instructions, guidance, and tips to the _Usage-Guide.md_ file---

View the [Usage Guide](./docs/Usage-Guide.md) for more detailed instructions.

Expand Down
35 changes: 15 additions & 20 deletions Repository-Setup.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## Delete me after project setup!

param (
[string]$ProjectName
)
Expand All @@ -12,7 +14,7 @@ $searchText = "Kentico.Xperience.RepoTemplate"
$replaceText = "$ProjectName"

$files = Get-ChildItem -Path "./" `
-Recurse:true | Where-Object {
-Recurse:$true | Where-Object {
@(".json", ".yml", ".props", ".md") -contains $_.Extension
}

Expand All @@ -31,42 +33,35 @@ foreach ($file in $files) {
Set-Content -Path $file.FullName -Value $newContent

Write-Host "Replaced text in file: $($file.FullName)"
} else {
Write-Host "No match found in file: $($file.FullName)"
}
}

# Define project directories
$srcProjectPath = "./src/$ProjectName"
$testProjectPath = "./tests/$ProjectName.Tests"
$examplesProjectPath = "./examples/DancingGoat"
$srcProjectPath = Join-Path "./src" $ProjectName
$testProjectPath = Join-Path "./tests" "$ProjectName.Tests"
$examplesProjectPath = Join-Path "./examples" "DancingGoat"

# Create the class library project
dotnet new classlib `
-n $ProjectName `
-o $srcProjectPath
-o $srcProjectPath `
--no-restore
Write-Host "Created class library project: $srcProjectPath"

# Create the NUnit test project
dotnet new nunit `
-n "$ProjectName.Tests" `
-o $testProjectPath
-o $testProjectPath `
--no-restore
Write-Host "Created NUnit test project: $testProjectPath"

# Add reference to the src project in the test project
dotnet new kentico-xperience-sample-mvc -n DancingGoat -o $examplesProjectPath --no-restore --allow-scripts Yes
Write-Host "Created Dancing Goat sample application: $examplesProjectPath"

dotnet add "$testProjectPath/$ProjectName.Tests.csproj" `
reference "$srcProjectPath/$ProjectName.csproj"
reference $srcProjectPath
Write-Host "Added reference from test project to class library project."

# Create the Dancing Goat sample application
dotnet new kentico-xperience-sample-mvc `
-n "DancingGoat" `
-o $examplesProjectPath --allow-scripts
Write-Host "Created Dancing Goat sample application: $examplesProjectPath"

# Add reference to the src project in the Dancing Goat sample application
dotnet add "$examplesProjectPath/DancingGoat.csproj" `
reference "$srcProjectPath/$ProjectName.csproj"
reference $srcProjectPath
Write-Host "Added reference from Dancing Goat project to class library project."

dotnet new sln -n "$ProjectName"
Expand Down

0 comments on commit c6039ff

Please sign in to comment.