private static string TestConsoleAppWithNetCoreClassLibrarySolution() { Project classLibProject = new NetCoreClassLibraryProject("NetCoreClassLibrary", NetCorePlatform.v2_0) .WithNugetPackage(Core.References.Nuget.Newtonsoft_Json__11_0_2); classLibProject.AddFileToFolder(new ProjectFile("HelloWorld.cs", true, false, CreateHelloWorldClassFile(classLibProject.RootNamespace).ToString())); classLibProject.AddFileToFolder(new ProjectFile("Test.txt", false, true, "Testing a simple text file creation.")); Project consoleAppProject = new NetCoreConsoleApplicationProject("NetCoreConsoleApp", NetCorePlatform.v2_0) .WithProjectReference(new ProjectReference(classLibProject, new RelativePathBuilder().AppendPath(RelativePath.Up_Directory).ToString())); consoleAppProject.AddFileToFolder(new ProjectFile("help.txt", false, true)); consoleAppProject.AddFileToFolder(new ProjectFile( new SGFile("Program.cs") { AssemblyReferences = { new SGAssemblyReference("System"), new SGAssemblyReference(classLibProject) }, Namespaces = { new SGNamespace(consoleAppProject.RootNamespace) { Classes = { new SGClass("Program", SGAccessibilityLevel.None) { Methods = { new SGMethod(new SGMethodSignature(accessibilityLevel: SGAccessibilityLevel.Private, methodName: "Main", returnType: "void", isStatic: true) { Arguments = { new SGArgument("string[]", "args") } }) { Lines = { $"Console.WriteLine(HelloWorld.Greeting);", "", "Console.ReadLine();" } } } } } } } })); return(new Solution("TestNetCoreSolution") .WithProject(classLibProject) .WithProject(consoleAppProject) .GenerateSolutionFiles(@"C:\")); }
public static SolutionWizard With_NetCoreConsoleApplication(this SolutionWizard wizard, string assemblyName, NetCorePlatform targetFrameworkVersion) { Project newConsoleApp = new NetCoreConsoleApplicationProject(assemblyName, targetFrameworkVersion); newConsoleApp.AddFileToFolder(new ProjectFile(SolutionWizard.CreateDefault_NetFramework_ConsoleProgram(assemblyName))); wizard.WithProject(newConsoleApp); return(wizard); }