public static SolutionWizard With_NetFrameworkConsoleApplication(this SolutionWizard wizard, string assemblyName, NetFrameworkPlatform targetFrameworkVersion) { Project newConsoleApp = new NetFrameworkConsoleApplicationCsProj(assemblyName, targetFrameworkVersion); newConsoleApp.AddFileToFolder(new AppConfigFile(targetFrameworkVersion)); newConsoleApp.AddFileToFolder(new ProjectFile(SolutionWizard.CreateDefault_NetFramework_ConsoleProgram(assemblyName))); wizard.WithProject(newConsoleApp); return(wizard); }
private static string TestConsoleAppWithNetFrameworkClassLibrarySolution() { Project classLibProject = new NetFrameworkClassLibraryProject("TestClassLibrary", NetFrameworkPlatform.v4_5_2) .WithNugetPackage(Core.References.Nuget.Newtonsoft_Json__10_0_1); //classLibProject.AddFileToFolder(new ProjectFile("Class1.cs", true, false, CreateEmptyClassFile("TestClassLibrary", "Class1").ToString())); 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 NetFrameworkConsoleApplicationCsProj("TestConsoleApplication", NetFrameworkPlatform.v4_5_2) .WithNugetPackage(Core.References.Nuget.Newtonsoft_Json__10_0_1) // Fully qualify //.WithProjectReference(new ProjectReference(classLibProject.AssemblyName, $@"..\{classLibProject.AssemblyName}\{classLibProject.AssemblyName}.csproj", classLibProject.AssemblyGuid)); // or .WithProjectReference(new ProjectReference(classLibProject, new RelativePathBuilder().AppendPath(RelativePath.Up_Directory).ToString())); //consoleAppProject.AddFileToFolder(new AppConfigFile(consoleAppProject.TargetFrameworkVersion)); consoleAppProject.AddFileToFolder(new ProjectFile("help.txt", false, true)); consoleAppProject.AddFileToFolder(new ProjectFile( new SGFile("Program.cs") { AssemblyReferences = { new SGAssemblyReference("System"), new SGAssemblyReference("System.Collections.Generic"), new SGAssemblyReference("System.Linq"), new SGAssemblyReference("System.Text"), new SGAssemblyReference("System.Threading.Tasks"), 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();" } } } } } } } })); Solution sln = new Solution("TestNetFrameworkSolution") .WithProject(classLibProject) .WithProject(consoleAppProject); return(sln.GenerateSolutionFiles(@"C:\")); }
private static string TestConsoleAppWithNetStandardClassLibrarySolution() { NetStandardPlatform netStandardPlatform = NetStandardPlatform.v1_6; Project classLibProject = new NetStandardClassLibraryProject("NetStandardClassLibrary", netStandardPlatform) .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 netFrameworkConsoleAppProject = new NetFrameworkConsoleApplicationCsProj("NetFrameworkConsoleApp", NetImplementationSupport.GetMinCompatibleWith(netStandardPlatform).NetFramework) .WithProjectReference(new ProjectReference(classLibProject, new RelativePathBuilder().AppendPath(RelativePath.Up_Directory).ToString())) .WithNugetPackage(Core.References.Nuget.Newtonsoft_Json__11_0_2); //netFrameworkConsoleAppProject.AddFileToFolder(new AppConfigFile(netFrameworkConsoleAppProject.TargetFrameworkVersion)); netFrameworkConsoleAppProject.AddFileToFolder(new ProjectFile( new SGFile("Program.cs") { AssemblyReferences = { new SGAssemblyReference("System"), new SGAssemblyReference("System.Collections.Generic"), new SGAssemblyReference("System.Linq"), new SGAssemblyReference("System.Text"), new SGAssemblyReference("System.Threading.Tasks"), new SGAssemblyReference(classLibProject) }, Namespaces = { new SGNamespace(netFrameworkConsoleAppProject.RootNamespace) { Classes = { new SGClass("Program", SGAccessibilityLevel.None) { Methods = { new SGMethod(new SGMethodSignature(accessibilityLevel: SGAccessibilityLevel.None, methodName: "Main", returnType: "void", isStatic: true) { Arguments = { new SGArgument("string[]", "args") } }) { Lines = { $"Console.WriteLine(HelloWorld.Greeting);", "", "Console.ReadLine();" } } } } } } } })); return(new Solution("TestNetStandardSolution") .WithProject(classLibProject) .WithProject(netFrameworkConsoleAppProject) .GenerateSolutionFiles(@"C:\")); }