コード例 #1
0
ファイル: Program.cs プロジェクト: chriszumberge/SlnGen
        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:\"));
        }
コード例 #2
0
        public static SolutionWizard With_NetCoreClassLibrary(this SolutionWizard wizard, string assemblyName, NetCorePlatform targetFrameworkVersion)
        {
            Project newProj = new NetCoreClassLibraryProject(assemblyName, targetFrameworkVersion);

            newProj.AddFileToFolder(new ProjectFile(SolutionWizard.CreateEmpty_NetFramework_ClassFile(assemblyName)));

            wizard.WithProject(newProj);

            return(wizard);
        }