{"id":7452,"date":"2023-03-01T16:07:12","date_gmt":"2023-03-01T15:07:12","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=7452"},"modified":"2025-01-15T11:40:12","modified_gmt":"2025-01-15T10:40:12","slug":"c-kickstart","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-kickstart\/","title":{"rendered":"C# Kickstart"},"content":{"rendered":"\n<p><strong>New solution + Classlib Project + Testproject<\/strong><\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"powershell\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">$AppName = Read-Host -Prompt 'Input your project (folder) name'\n$TargetFolder=\"$AppName\"\nWrite-Host \"Creating a new project '$AppName' in '$TargetFolder'\"\n$confirmation = Read-Host \"Are you sure you want to proceed? [y\/N]\"\nif ($confirmation -ne 'y') {\n    Write-Host \"Closing..\"\n    Start-Sleep -Seconds 2\n    Exit\n}\nNew-Item -ItemType Directory -Force -Path $TargetFolder\nPush-Location $TargetFolder\ngit init\n# solution\ndotnet new sln -n $AppName\ndotnet new gitignore\ndotnet new globaljson\ndotnet new nugetconfig\n\ndotnet new classlib -n $AppName\ndotnet sln add $AppName\n\n# unit test project\n$TestProject = \"$AppName.Tests\";\ndotnet new nunit -n $TestProject\ndotnet add $TestProject package NSubstitute\ndotnet sln add $TestProject\ndotnet add $TestProject reference $AppName<\/pre><\/div>\n\n\n\n<p>New WebApi solution with database adapters<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"powershell\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">$AppName = Read-Host -Prompt 'Input your project (folder) name'\n$TargetFolder=\".\/$AppName\"\n$AppNameTitleCase = (Get-Culture).TextInfo.ToTitleCase($AppName)\n#$path = Get-Location\n#$newPath = Join-Path -Path $path -ChildPath $TargetFolder\nWrite-Host \"Creating a new project '$AppNameTitleCase' in '$TargetFolder'\"\n$confirmation = Read-Host \"Are you sure you want to proceed? [y\/N]\"\nif ($confirmation -ne 'y') {\n    Write-Host \"Closing..\"\n    Start-Sleep -Seconds 2\n    Exit\n}\nNew-Item -ItemType Directory -Force -Path $TargetFolder\nPush-Location $TargetFolder\n\n# pick what you need:\n\n# init git\ngit init\n\n# solution\ndotnet new sln -n $AppNameTitleCase\ndotnet new gitignore\ndotnet new globaljson\ndotnet new nugetconfig\n# domain project\ndotnet new classlib -n Domain\ndotnet sln add Domain\n# unit test project\ndotnet new nunit -n Domain.Tests\ndotnet add Domain.Tests package NSubstitute\ndotnet sln add Domain.Tests\ndotnet add Domain.Tests reference Domain\n\n# adapter project(s)\ndotnet new classlib -n LicenseDbAdapter\ndotnet sln add LicenseDbAdapter\ndotnet add LicenseDbAdapter reference Domain\n\ndotnet new classlib -n DbAdapter\ndotnet sln add DbAdapter\ndotnet add DbAdapter reference Domain\n\n# wiring project\ndotnet new classlib -n Wiring\ndotnet sln add Wiring\ndotnet add Wiring reference Domain\ndotnet add Wiring reference LicenseDbAdapter\ndotnet add Wiring reference DbAdapter\n# use webapi and\/or console\n# webapi project\ndotnet new webapi -n WebApi\ndotnet sln add WebApi\ndotnet add WebApi reference Domain\ndotnet add WebApi reference Wiring\n\n# console project\n#dotnet new console -n ConsoleApp\n#dotnet sln add ConsoleApp\n#dotnet add ConsoleApp reference Domain\n#dotnet add ConsoleApp reference Wiring\n\nPop-Location\n\n# # copy content files\n# Copy-Item -Path \"files\/AssemblyInfo.cs\" -Destination \"$TargetFolder\/Domain\"\n# Copy-Item -Path \"files\/DomainPorts.cs\" -Destination \"$TargetFolder\/Domain\"\n# Copy-Item -Path \"files\/IAdapterResolver.cs\" -Destination \"$TargetFolder\/Domain\"\n# Copy-Item -Path \"files\/Wiring.cs\" -Destination \"$TargetFolder\/Wiring\"\n\n# # remove unused files\n# Remove-Item \"$TargetFolder\/Domain\/Class1.cs\" -ErrorAction Ignore\n# Remove-Item \"$TargetFolder\/Domain.Tests\/Class1.cs\" -ErrorAction Ignore\n# Remove-Item \"$TargetFolder\/Adapters\/Class1.cs\" -ErrorAction Ignore\n# Remove-Item \"$TargetFolder\/Wiring\/Class1.cs\" -ErrorAction Ignore\n\n#if (Test-Path $FileName) \n#{\n#    Remove-Item $FileName\n#}\n\nWrite-Host \"Finished\"\n<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>New solution + Classlib Project + Testproject New WebApi solution with database adapters<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6,26],"tags":[],"class_list":["post-7452","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-project-structure"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=7452"}],"version-history":[{"count":3,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7452\/revisions"}],"predecessor-version":[{"id":7594,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7452\/revisions\/7594"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=7452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=7452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=7452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}