public static SolutionWizard With_NetFrameworkClassLibrary(this SolutionWizard wizard, string assemblyName, NetFrameworkPlatform targetFrameworkVersion) { Project newProj = new NetFrameworkClassLibraryProject(assemblyName, targetFrameworkVersion); newProj.AddFileToFolder(new ProjectFile(SolutionWizard.CreateEmpty_NetFramework_ClassFile(assemblyName))); wizard.WithProject(newProj); 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:\")); }