question

HaraldBacik-3378 avatar image
0 Votes"
HaraldBacik-3378 asked HaraldBacik-3378 commented

Creating new classlibrary project environment independent

Hey
I use Visual Studio Pro on Windows. Within my code, I create a new class library, which works really fine.
But I don't have a Mac / or Visual Studio Code to test, if this code would run environment independent.

 {
     Process locProcess = new Process();
     ProcessStartInfo locProcessStartInfo = new ProcessStartInfo();
     locProcessStartInfo.RedirectStandardOutput = false;
     locProcessStartInfo.FileName = "dotnet";
     locProcessStartInfo.Arguments = $"new classlib -o ""{myBaseProjectFolder}"" -f ""{typeOfProject}"" -lang ""{myProjectLanguage}"" --force";
     locProcess.StartInfo = locProcessStartInfo;
     var locProcessEnded = locProcess.Start();
     locProcess.WaitForExit();
 }

Based on the idea, I have a .NET Standard 2.0 project, I would guess, that i should work!?
Could someone maybe test for me - or does someone know, if it will work?

THX a lot in advance

dotnet-csharp
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@HaraldBacik-3378, based on my test, I could use your code to create the classlibrary successfully in visual studio code with the following parameters:

 string myBaseProjectFolder = @"E:\Example\TestLib";
 string typeOfProject = "net6.0";
 string myProjectLanguage = "C#";
 locProcessStartInfo.Arguments = $@"new classlib -o ""{myBaseProjectFolder}"" -f ""{typeOfProject}"" -lang ""{myProjectLanguage}"" --force";







0 Votes 0 ·

Hey
THX a lot for testing it out!

0 Votes 0 ·

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

assuming you fix the syntax error on line 6, it work fine.

locProcessStartInfo.Arguments = $@"new classlib -o ""{myBaseProjectFolder}"" -f ""{typeOfProject}"" -lang ""{myProjectLanguage}"" --force";

note: The syntax for file paths is different across platform:



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.