C
C#7mo ago
Core

✅ How to create a folder in project root?

Hi, I am trying to put the project library/libraries in a src folder. I can only create a solution folder. The files are only structured that way if I the project is opened with an IDE, otherwise those solution folders do not exist if viewed with file explorer. Is this really how a project is structured? Let's say I have 5 libraries and 3 other test libraries. This way if I went to the git repository all the class libraries would be mixed. How could I create a src and test folder in project root? Is that even possible?
No description
No description
5 Replies
Pobiega
Pobiega7mo ago
its absolutely possible, but you need to do it outside of visual studio the simplest way is just to just create the folders manually, remove all project dependencies, move your projects as you want them, re-link them the solution file is old and bad, we're about to get a new format for it soon thank god
Core
CoreOP7mo ago
Thank you, I will try that
Pobiega
Pobiega7mo ago
Ah, found the tag $scaffolding
MODiX
MODiX7mo ago
https://media.discordapp.net/attachments/569261465463160900/1044277486508331198/image.png using the CLI:
mkdir Foo
cd Foo

git init
dotnet new gitignore

# take the name of the current folder
dotnet new sln
# similar as:
# dotnet new sln -n Foo

dotnet new nugetconfig
dotnet new editorconfig
dotnet new tool-manifest

mkdir src
mkdir test
mkdir samples # for later use
mkdir benchmarks # for later use

dotnet new webapi -o src/Foo.Web
dotnet new classlib -o src/Foo.Domain
dotnet add ./src/Foo.Web reference ./src/Foo.Domain

dotnet new xunit -o test/Foo.Web.Tests
dotnet new xunit -o test/Foo.Domain.Tests
dotnet add ./test/Foo.Web.Tests reference ./src/Foo.Web
dotnet add ./test/Foo.Domain.Tests reference ./src/Foo.Domain

dotnet sln add ./src/Foo.Web
dotnet sln add ./src/Foo.Domain
dotnet sln add ./test/Foo.Web.Tests
dotnet sln add ./test/Foo.Domain.Tests

git add .
git commit -m "Initial commit"

dotnet tool restore
dotnet restore
dotnet format
dotnet build
dotnet test
mkdir Foo
cd Foo

git init
dotnet new gitignore

# take the name of the current folder
dotnet new sln
# similar as:
# dotnet new sln -n Foo

dotnet new nugetconfig
dotnet new editorconfig
dotnet new tool-manifest

mkdir src
mkdir test
mkdir samples # for later use
mkdir benchmarks # for later use

dotnet new webapi -o src/Foo.Web
dotnet new classlib -o src/Foo.Domain
dotnet add ./src/Foo.Web reference ./src/Foo.Domain

dotnet new xunit -o test/Foo.Web.Tests
dotnet new xunit -o test/Foo.Domain.Tests
dotnet add ./test/Foo.Web.Tests reference ./src/Foo.Web
dotnet add ./test/Foo.Domain.Tests reference ./src/Foo.Domain

dotnet sln add ./src/Foo.Web
dotnet sln add ./src/Foo.Domain
dotnet sln add ./test/Foo.Web.Tests
dotnet sln add ./test/Foo.Domain.Tests

git add .
git commit -m "Initial commit"

dotnet tool restore
dotnet restore
dotnet format
dotnet build
dotnet test
Foo/
|-.config/
|-dotnet-tools.json
|-src/
|-Foo.Web/
|-Foo.Web.csproj
|-Foo.Domain/
|-Foo.Domain.csproj/
|-test/
|-Foo.Web.Tests/
|-Foo.Web.Tests.csproj
|-Foo.Domain.Tests/
|-Foo.Domain.Tests.csproj/
|-Foo.sln
|-nuget.config
|-.editorconfig
Foo/
|-.config/
|-dotnet-tools.json
|-src/
|-Foo.Web/
|-Foo.Web.csproj
|-Foo.Domain/
|-Foo.Domain.csproj/
|-test/
|-Foo.Web.Tests/
|-Foo.Web.Tests.csproj
|-Foo.Domain.Tests/
|-Foo.Domain.Tests.csproj/
|-Foo.sln
|-nuget.config
|-.editorconfig
Core
CoreOP7mo ago
Great! Thanks
Want results from more Discord servers?
Add your server