Exemple #1
0
        public static SolutionWizard With_NetStandardClassLibrary(this SolutionWizard wizard, string assemblyName, NetStandardPlatform targetFrameworkVersion)
        {
            Project newProj = new NetStandardClassLibraryProject(assemblyName, targetFrameworkVersion);

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

            wizard.WithProject(newProj);

            return(wizard);
        }
Exemple #2
0
        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:\"));
        }