Beispiel #1
0
        public void DoSetup()
        {
            string vmdir    = MainDir;
            string datadir  = MainDir;
            string modeldir = MainDir;
            string vmns     = MainNs + ".ViewModels";
            string datans   = MainNs;
            string modelns  = MainNs;

            if (ProjectType == ProjectTypeEnum.Single)
            {
                Directory.CreateDirectory($"{MainDir}\\Models");
                Directory.CreateDirectory($"{MainDir}\\ViewModels\\HomeVMs");
                vmdir = MainDir + "\\ViewModels";
            }
            else
            {
                Directory.CreateDirectory($"{MainDir}.ViewModel\\HomeVMs");
                Directory.CreateDirectory($"{MainDir}.Model");
                Directory.CreateDirectory($"{MainDir}.DataAccess");
                vmdir    = MainDir + ".ViewModel";
                datadir  = MainDir + ".DataAccess";
                modeldir = MainDir + ".Model";
                vmns     = MainNs + ".ViewModel";
                datans   = MainNs + ".DataAccess";
                modelns  = MainNs + ".Model";
                File.WriteAllText($"{modeldir}\\{modelns}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
                File.WriteAllText($"{vmdir}\\{vmns}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
                File.WriteAllText($"{datadir}\\{datans}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
            }
            Directory.CreateDirectory($"{MainDir}\\Areas");
            Directory.CreateDirectory($"{MainDir}\\Controllers");
            Directory.CreateDirectory($"{MainDir}\\Views\\Home");
            Directory.CreateDirectory($"{MainDir}\\Views\\Login");
            Directory.CreateDirectory($"{MainDir}\\Views\\Shared");
            Directory.CreateDirectory($"{MainDir}\\wwwroot");

            File.WriteAllText($"{MainDir}\\appsettings.json", GetResource("Appsettings.txt")
                              .Replace("$cs$", CS ?? "")
                              .Replace("$dbtype$", DbType.ToString())
                              .Replace("$cookiepre$", CookiePre ?? "")
                              .Replace("$enablelog$", EnableLog.ToString().ToLower())
                              .Replace("$logexception$", LogExceptionOnly.ToString().ToLower())
                              .Replace("$rpp$", Rpp == null ? "" : Rpp.ToString())
                              .Replace("$filemode$", FileMode.ToString())
                              .Replace("$uploaddir$", UploadDir ?? ""), Encoding.UTF8
                              );
            File.WriteAllText($"{datadir}\\DataContext.cs", GetResource("DataContext.txt").Replace("$ns$", datans), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Controllers\\HomeController.cs", GetResource("HomeController.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Controllers\\LoginController.cs", GetResource("LoginController.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Views\\_ViewStart.cshtml", GetResource("ViewStart.txt"), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Views\\Home\\Index.cshtml", GetResource("home.Index.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Views\\Login\\ChangePassword.cshtml", GetResource("home.ChangePassword.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Views\\Home\\Header.cshtml", GetResource("home.Header.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Views\\Login\\Login.cshtml", GetResource("home.Login.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Views\\Home\\Menu.cshtml", GetResource("home.Menu.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Views\\Home\\PIndex.cshtml", GetResource("home.PIndex.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{MainDir}\\Views\\Home\\FrontPage.cshtml", GetResource("home.FrontPage.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{vmdir}\\HomeVMs\\ChangePasswordVM.cs", GetResource("vms.ChangePasswordVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{vmdir}\\HomeVMs\\IndexVM.cs", GetResource("vms.IndexVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
            File.WriteAllText($"{vmdir}\\HomeVMs\\LoginVM.cs", GetResource("vms.LoginVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);

            if (UI == UIEnum.LayUI)
            {
                File.WriteAllText($"{MainDir}\\Views\\Shared\\_Layout.cshtml", GetResource("layui.Layout.txt").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Shared\\_PLayout.cshtml", GetResource("layui.PLayout.txt").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Program.cs", GetResource("layui.Program.txt").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\_ViewImports.cshtml", GetResource("layui.ViewImports.txt"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Areas\\_ViewImports.cshtml", GetResource("layui.ViewImports.txt"), Encoding.UTF8);
                Assembly assembly = Assembly.GetExecutingAssembly();
                var      sr       = assembly.GetManifestResourceStream($"WalkingTec.Mvvm.Mvc.SetupFiles.layui.layui.zip");
                System.IO.Compression.ZipArchive zip = new System.IO.Compression.ZipArchive(sr);
                foreach (var entry in zip.Entries)
                {
                    if (entry.FullName.EndsWith("/"))
                    {
                        Directory.CreateDirectory($"{MainDir}\\wwwroot\\{entry.FullName}");
                    }
                    else
                    {
                        var f = File.OpenWrite($"{MainDir}\\wwwroot\\{entry.FullName}");
                        var z = entry.Open();
                        z.CopyTo(f);
                        f.Flush();
                        f.Dispose();
                        z.Dispose();
                    }
                }
                sr.Dispose();
            }
            if (ProjectType == ProjectTypeEnum.Single)
            {
                var proj = File.ReadAllText($"{MainDir}\\{MainNs}.csproj");
                if (proj.IndexOf("WalkingTec.Mvvm.TagHelpers.LayUI") < 0)
                {
                    proj = proj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" />
    <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{MainDir}\\{MainNs}.csproj", proj, Encoding.UTF8);
                }
            }
            if (ProjectType == ProjectTypeEnum.Multi)
            {
                var proj = File.ReadAllText($"{MainDir}\\{MainNs}.csproj");
                if (proj.IndexOf("WalkingTec.Mvvm.TagHelpers.LayUI") < 0)
                {
                    proj = proj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" />
    <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" />
    <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
    <ProjectReference Include=""..\{datans}\{datans}.csproj"" />
    <ProjectReference Include=""..\{vmns}\{vmns}.csproj"" />
 </ItemGroup >
</Project>
");
                    File.WriteAllText($"{MainDir}\\{MainNs}.csproj", proj, Encoding.UTF8);
                }
                //修改modelproject
                var modelproj = File.ReadAllText($"{modeldir}\\{modelns}.csproj");
                if (modelproj.IndexOf("WalkingTec.Mvvm.Core") < 0)
                {
                    modelproj = modelproj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.Core"" Version=""{version}"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{modeldir}\\{modelns}.csproj", modelproj, Encoding.UTF8);
                }
                //修改dataproject
                var dataproj = File.ReadAllText($"{datadir}\\{datans}.csproj");
                if (dataproj.IndexOf($"{modelns}.csproj") < 0)
                {
                    dataproj = dataproj.Replace("</Project>", $@"
  <ItemGroup>
    <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{datadir}\\{datans}.csproj", dataproj, Encoding.UTF8);
                }
                //修改viewmodelproject
                var vmproj = File.ReadAllText($"{vmdir}\\{vmns}.csproj");
                if (vmproj.IndexOf($"{modelns}.csproj") < 0)
                {
                    vmproj = vmproj.Replace("</Project>", $@"
  <ItemGroup>
    <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{vmdir}\\{vmns}.csproj", vmproj, Encoding.UTF8);
                }
                var solution = File.ReadAllText($"{Directory.GetParent(MainDir)}\\{MainNs}.sln");
                if (solution.IndexOf($"{modelns}.csproj") < 0)
                {
                    Guid g1 = Guid.NewGuid();
                    Guid g2 = Guid.NewGuid();
                    Guid g3 = Guid.NewGuid();
                    solution = solution.Replace("EndProject", $@"EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{modelns}"", ""{modelns}\{modelns}.csproj"", ""{{{g1}}}""
EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{datans}"", ""{datans}\{datans}.csproj"", ""{{{g2}}}""
EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{vmns}"", ""{vmns}\{vmns}.csproj"", ""{{{g3}}}""
EndProject
");
                    solution = solution.Replace(".Release|Any CPU.Build.0 = Release|Any CPU", $@".Release|Any CPU.Build.0 = Release|Any CPU
		{{{g1}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g1}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g1}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g1}}}.Release|Any CPU.Build.0 = Release|Any CPU
		{{{g2}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g2}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g2}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g2}}}.Release|Any CPU.Build.0 = Release|Any CPU
		{{{g3}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g3}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g3}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g3}}}.Release|Any CPU.Build.0 = Release|Any CPU"        );
                    File.WriteAllText($"{Directory.GetParent(MainDir)}\\{MainNs}.sln", solution, Encoding.UTF8);
                }
            }
            if (File.Exists($"{MainDir}\\Startup.cs"))
            {
                File.Delete($"{MainDir}\\Startup.cs");
            }
        }
Beispiel #2
0
        public void DoSetup()
        {
            string vmdir    = MainDir;
            string datadir  = MainDir;
            string modeldir = MainDir;
            string vmns     = MainNs + ".ViewModels";
            string datans   = MainNs;
            string modelns  = MainNs;

            if (ProjectType == ProjectTypeEnum.Single)
            {
                Directory.CreateDirectory($"{MainDir}\\Models");
                File.WriteAllText($"{MainDir}\\Models\\ReadMe.txt", "Put your models here");
                Directory.CreateDirectory($"{MainDir}\\ViewModels\\HomeVMs");
                vmdir = MainDir + "\\ViewModels";
            }
            else
            {
                Directory.CreateDirectory($"{MainDir}.ViewModel\\HomeVMs");
                Directory.CreateDirectory($"{MainDir}.Model");
                Directory.CreateDirectory($"{MainDir}.DataAccess");
                vmdir    = MainDir + ".ViewModel";
                datadir  = MainDir + ".DataAccess";
                modeldir = MainDir + ".Model";
                vmns     = MainNs + ".ViewModel";
                datans   = MainNs + ".DataAccess";
                modelns  = MainNs + ".Model";
                File.WriteAllText($"{modeldir}\\{modelns}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
                File.WriteAllText($"{vmdir}\\{vmns}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
                File.WriteAllText($"{datadir}\\{datans}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
            }
            Directory.CreateDirectory($"{MainDir}\\Areas");
            Directory.CreateDirectory($"{MainDir}\\Controllers");
            if (UI == UIEnum.LayUI)
            {
                Directory.CreateDirectory($"{MainDir}\\Views\\Home");
                Directory.CreateDirectory($"{MainDir}\\Views\\Login");
                Directory.CreateDirectory($"{MainDir}\\Views\\Shared");
            }
            Directory.CreateDirectory($"{MainDir}\\wwwroot");

            var proj = File.ReadAllText($"{MainDir}\\{MainNs}.csproj");

            if (UI == UIEnum.LayUI)
            {
                proj = proj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" />
    <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" />
 </ItemGroup>
</Project>
");
                proj = proj.Replace("</PropertyGroup>", $@"
    <CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>
");
            }
            if (UI == UIEnum.React)
            {
                proj = proj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" />
    <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" />
    <PackageReference Include=""Swashbuckle.AspNetCore"" Version=""4.0.1"" />
 </ItemGroup>
  <ItemGroup>
    <Content Remove=""$(SpaRoot)**"" />
    <None Include=""$(SpaRoot)**"" Exclude=""$(SpaRoot)node_modules\**;$(SpaRoot).awcache\**;$(SpaRoot).cache-loader\**"" />
  </ItemGroup>
  <Target Name=""DebugEnsureNodeEnv"" BeforeTargets=""Build"" Condition="" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') "">
    <Exec Command=""node --version"" ContinueOnError=""true"">
      <Output TaskParameter=""ExitCode"" PropertyName=""ErrorCode"" />
    </Exec>
    <Error Condition=""'$(ErrorCode)' != '0'"" Text=""Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE."" />
    <Message Importance=""high"" Text=""Restoring dependencies using 'npm'. This may take several minutes..."" />
    <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm install"" />
  </Target>
  <Target Name=""PublishRunWebpack"" AfterTargets=""ComputeFilesToPublish"">
    <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm install"" />
    <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm run build"" />
    <ItemGroup>
      <DistFiles Include=""$(SpaRoot)build\**"" />
      <ResolvedFileToPublish Include=""@(DistFiles->'%(FullPath)')"" Exclude=""@(ResolvedFileToPublish)"">
        <RelativePath>%(DistFiles.Identity)</RelativePath>
        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      </ResolvedFileToPublish>
    </ItemGroup>
  </Target>
</Project>
");
                proj = proj.Replace("</PropertyGroup>", $@"
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
    <TypeScriptToolsVersion>3.2</TypeScriptToolsVersion>
    <IsPackable>false</IsPackable>
    <SpaRoot>ClientApp\</SpaRoot>
    <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
    <CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>
");
            }

            if (ProjectType == ProjectTypeEnum.Multi)
            {
                proj = proj.Replace("</Project>", $@"
  <ItemGroup>
   <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
    <ProjectReference Include=""..\{datans}\{datans}.csproj"" />
    <ProjectReference Include=""..\{vmns}\{vmns}.csproj"" />
 </ItemGroup >
</Project>
");
            }

            File.WriteAllText($"{MainDir}\\{MainNs}.csproj", proj, Encoding.UTF8);
            if (ProjectType == ProjectTypeEnum.Multi)
            {
                //修改modelproject
                var modelproj = File.ReadAllText($"{modeldir}\\{modelns}.csproj");
                if (modelproj.IndexOf("WalkingTec.Mvvm.Core") < 0)
                {
                    modelproj = modelproj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.Core"" Version=""{version}"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{modeldir}\\{modelns}.csproj", modelproj, Encoding.UTF8);
                }
                //修改dataproject
                var dataproj = File.ReadAllText($"{datadir}\\{datans}.csproj");
                if (dataproj.IndexOf($"{modelns}.csproj") < 0)
                {
                    dataproj = dataproj.Replace("</Project>", $@"
  <ItemGroup>
    <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{datadir}\\{datans}.csproj", dataproj, Encoding.UTF8);
                }
                //修改viewmodelproject
                var vmproj = File.ReadAllText($"{vmdir}\\{vmns}.csproj");
                if (vmproj.IndexOf($"{modelns}.csproj") < 0)
                {
                    vmproj = vmproj.Replace("</Project>", $@"
  <ItemGroup>
    <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{vmdir}\\{vmns}.csproj", vmproj, Encoding.UTF8);
                }
                var solution = File.ReadAllText($"{Directory.GetParent(MainDir)}\\{MainNs}.sln");
                if (solution.IndexOf($"{modelns}.csproj") < 0)
                {
                    Guid g1 = Guid.NewGuid();
                    Guid g2 = Guid.NewGuid();
                    Guid g3 = Guid.NewGuid();
                    solution = solution.Replace("EndProject", $@"EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{modelns}"", ""{modelns}\{modelns}.csproj"", ""{{{g1}}}""
EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{datans}"", ""{datans}\{datans}.csproj"", ""{{{g2}}}""
EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{vmns}"", ""{vmns}\{vmns}.csproj"", ""{{{g3}}}""
EndProject
");
                    solution = solution.Replace(".Release|Any CPU.Build.0 = Release|Any CPU", $@".Release|Any CPU.Build.0 = Release|Any CPU
		{{{g1}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g1}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g1}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g1}}}.Release|Any CPU.Build.0 = Release|Any CPU
		{{{g2}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g2}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g2}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g2}}}.Release|Any CPU.Build.0 = Release|Any CPU
		{{{g3}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g3}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g3}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g3}}}.Release|Any CPU.Build.0 = Release|Any CPU"        );
                    File.WriteAllText($"{Directory.GetParent(MainDir)}\\{MainNs}.sln", solution, Encoding.UTF8);
                }
            }


            File.WriteAllText($"{MainDir}\\appsettings.json", GetResource("Appsettings.txt")
                              .Replace("$cs$", CS ?? "")
                              .Replace("$dbtype$", DbType.ToString())
                              .Replace("$pagemode$", PageMode.ToString())
                              .Replace("$cookiepre$", CookiePre ?? "")
                              .Replace("$enablelog$", EnableLog.ToString().ToLower())
                              .Replace("$logexception$", LogExceptionOnly.ToString().ToLower())
                              .Replace("$rpp$", Rpp == null ? "" : Rpp.ToString())
                              .Replace("$filemode$", FileMode.ToString())
                              .Replace("$uploaddir$", UploadDir ?? ""), Encoding.UTF8
                              );
            File.WriteAllText($"{datadir}\\DataContext.cs", GetResource("DataContext.txt").Replace("$ns$", datans), Encoding.UTF8);
            if (UI == UIEnum.LayUI)
            {
                File.WriteAllText($"{MainDir}\\Controllers\\HomeController.cs", GetResource("HomeController.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Controllers\\LoginController.cs", GetResource("LoginController.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\_ViewStart.cshtml", GetResource("ViewStart.txt", "Mvc"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Home\\Index.cshtml", GetResource("home.Index.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Login\\ChangePassword.cshtml", GetResource("home.ChangePassword.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Home\\Header.cshtml", GetResource("home.Header.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Login\\Login.cshtml", GetResource("home.Login.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Home\\Menu.cshtml", GetResource("home.Menu.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Home\\PIndex.cshtml", GetResource("home.PIndex.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Home\\FrontPage.cshtml", GetResource("home.FrontPage.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{vmdir}\\HomeVMs\\ChangePasswordVM.cs", GetResource("vms.ChangePasswordVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{vmdir}\\HomeVMs\\IndexVM.cs", GetResource("vms.IndexVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{vmdir}\\HomeVMs\\LoginVM.cs", GetResource("vms.LoginVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Shared\\_Layout.cshtml", GetResource("layui.Layout.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\Shared\\_PLayout.cshtml", GetResource("layui.PLayout.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Program.cs", GetResource("layui.Program.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Views\\_ViewImports.cshtml", GetResource("layui.ViewImports.txt", "Mvc"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}\\Areas\\_ViewImports.cshtml", GetResource("layui.ViewImports.txt", "Mvc"), Encoding.UTF8);
                UnZip("WalkingTec.Mvvm.Mvc.SetupFiles.Mvc.layui.layui.zip", $"{MainDir}\\wwwroot");
            }
            if (UI == UIEnum.React)
            {
                Directory.CreateDirectory($"{MainDir}\\ClientApp");
                UnZip("WalkingTec.Mvvm.Mvc.SetupFiles.Mvc.layui.layui.zip", $"{MainDir}\\wwwroot");
                UnZip("WalkingTec.Mvvm.Mvc.SetupFiles.Spa.React.ClientApp.zip", $"{MainDir}\\ClientApp");
                File.WriteAllText($"{MainDir}\\Program.cs", GetResource("Program.txt", "Spa").Replace("$ns$", MainNs), Encoding.UTF8);
                var config = File.ReadAllText($"{MainDir}\\ClientApp\\src\\global.config.tsx");
                File.WriteAllText($"{MainDir}\\ClientApp\\src\\global.config.tsx", config.Replace("title: \"WalkingTec MVVM\",", $"title: \"{MainNs}\","), Encoding.UTF8);
            }

            if (File.Exists($"{MainDir}\\Startup.cs"))
            {
                File.Delete($"{MainDir}\\Startup.cs");
            }
        }
Beispiel #3
0
        public void DoSetup()
        {
            switch (DotnetVersion)
            {
            case DotnetVersionEnum.dotnet2_2:
                EFDesignVersion    = "2.2.4";
                SwashbuckleVersion = "4.0.1";
                version            = Utils.GetNugetVersion("2.", false);
                break;

            case DotnetVersionEnum.dotnet3_0:
                EFDesignVersion    = "3.0.1";
                SwashbuckleVersion = "5.0.0-rc4";
                version            = Utils.GetNugetVersion("3.", true);
                break;

            default:
                break;
            }

            string vmdir       = MainDir;
            string datadir     = MainDir;
            string modeldir    = MainDir;
            string resourcedir = MainDir + $"{Path.DirectorySeparatorChar}Resources";
            string testdir     = MainDir + ".Test";
            string vmns        = MainNs + ".ViewModels";
            string datans      = MainNs;
            string modelns     = MainNs;
            string testns      = MainNs + ".Test";

            Directory.CreateDirectory($"{MainDir}.Test");
            Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Resources");
            if (ProjectType == ProjectTypeEnum.Single)
            {
                Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Models");
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Models{Path.DirectorySeparatorChar}ReadMe.txt", "Put your models here");
                Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}ViewModels");
                if (UI == UIEnum.LayUI)
                {
                    Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}ViewModels{Path.DirectorySeparatorChar}HomeVMs");
                }
                vmdir = MainDir + $"{Path.DirectorySeparatorChar}ViewModels";
            }
            else
            {
                Directory.CreateDirectory($"{MainDir}.ViewModel");
                if (UI == UIEnum.LayUI)
                {
                    Directory.CreateDirectory($"{MainDir}.ViewModel{Path.DirectorySeparatorChar}HomeVMs");
                }
                Directory.CreateDirectory($"{MainDir}.Model");
                Directory.CreateDirectory($"{MainDir}.DataAccess");
                vmdir    = MainDir + ".ViewModel";
                datadir  = MainDir + ".DataAccess";
                modeldir = MainDir + ".Model";
                vmns     = MainNs + ".ViewModel";
                datans   = MainNs + ".DataAccess";
                modelns  = MainNs + ".Model";
                File.WriteAllText($"{modeldir}{Path.DirectorySeparatorChar}{modelns}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
                File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}{vmns}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
                File.WriteAllText($"{datadir}{Path.DirectorySeparatorChar}{datans}.csproj", GetResource("Proj.txt"), Encoding.UTF8);
            }
            File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}{testns}.csproj", GetResource("TestProj.txt").Replace("$ns$", MainNs), Encoding.UTF8);
            File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}MockController.cs", GetResource("MockController.txt", "test").Replace("$ns$", testns).Replace("$datans$", datans), Encoding.UTF8);
            File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}MockHttpSession.cs", GetResource("MockHttpSession.txt", "test").Replace("$ns$", testns), Encoding.UTF8);
            Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Areas");
            Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Controllers");
            if (UI == UIEnum.LayUI)
            {
                File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}HomeControllerTest.cs", GetResource("HomeControllerTest.txt", "test").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{testdir}{Path.DirectorySeparatorChar}LoginControllerTest.cs", GetResource("LoginControllerTest.txt", "test").Replace("$ns$", MainNs).Replace("$vmns$", vmns).Replace("$datans$", datans), Encoding.UTF8);
                Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home");
                Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Login");
                Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Shared");
            }
            Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}wwwroot");

            var proj = File.ReadAllText($"{MainDir}{Path.DirectorySeparatorChar}{MainNs}.csproj");

            if (UI == UIEnum.LayUI)
            {
                proj = proj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" />
    <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" />
    <PackageReference Include=""Swashbuckle.AspNetCore"" Version=""{SwashbuckleVersion}"" />
    <PackageReference Include=""Microsoft.EntityFrameworkCore.Design"" Version=""{EFDesignVersion}"" />
</ItemGroup>
</Project>
");
                proj = proj.Replace("</PropertyGroup>", $@"
    <CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>
");
            }
            if (UI == UIEnum.React)
            {
                proj = proj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.TagHelpers.LayUI"" Version=""{version}"" />
    <PackageReference Include=""WalkingTec.Mvvm.Mvc.Admin"" Version=""{version}"" />
    <PackageReference Include=""Swashbuckle.AspNetCore"" Version=""{SwashbuckleVersion}"" />
    <PackageReference Include=""Microsoft.EntityFrameworkCore.Design"" Version=""{EFDesignVersion}"" />
 </ItemGroup>
  <ItemGroup>
    <Content Remove=""$(SpaRoot)**"" />
    <None Include=""$(SpaRoot)**"" Exclude=""$(SpaRoot)node_modules\**;$(SpaRoot).awcache\**;$(SpaRoot).cache-loader\**"" />
  </ItemGroup>
  <Target Name=""DebugEnsureNodeEnv"" BeforeTargets=""Build"" Condition="" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') "">
    <Exec Command=""node --version"" ContinueOnError=""true"">
      <Output TaskParameter=""ExitCode"" PropertyName=""ErrorCode"" />
    </Exec>
    <Error Condition=""'$(ErrorCode)' != '0'"" Text=""Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE."" />
    <Message Importance=""high"" Text=""Restoring dependencies using 'npm'. This may take several minutes..."" />
    <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm install"" />
  </Target>
  <Target Name=""PublishRunWebpack"" AfterTargets=""ComputeFilesToPublish"">
    <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm install"" />
    <Exec WorkingDirectory=""$(SpaRoot)"" Command=""npm run build"" />
    <ItemGroup>
      <DistFiles Include=""$(SpaRoot)build\**"" />
      <ResolvedFileToPublish Include=""@(DistFiles->'%(FullPath)')"" Exclude=""@(ResolvedFileToPublish)"">
        <RelativePath>%(DistFiles.Identity)</RelativePath>
        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      </ResolvedFileToPublish>
    </ItemGroup>
  </Target>
</Project>
");
                proj = proj.Replace("</PropertyGroup>", $@"
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
    <TypeScriptToolsVersion>3.2</TypeScriptToolsVersion>
    <IsPackable>false</IsPackable>
    <SpaRoot>ClientApp\</SpaRoot>
    <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
    <CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>
");
            }

            if (ProjectType == ProjectTypeEnum.Multi)
            {
                proj = proj.Replace("</Project>", $@"
  <ItemGroup>
   <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
    <ProjectReference Include=""..\{datans}\{datans}.csproj"" />
    <ProjectReference Include=""..\{vmns}\{vmns}.csproj"" />
 </ItemGroup >
</Project>
");
            }

            File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}{MainNs}.csproj", proj, Encoding.UTF8);
            if (ProjectType == ProjectTypeEnum.Multi)
            {
                //修改modelproject
                var modelproj = File.ReadAllText($"{modeldir}{Path.DirectorySeparatorChar}{modelns}.csproj");
                if (modelproj.IndexOf("WalkingTec.Mvvm.Core") < 0)
                {
                    modelproj = modelproj.Replace("</Project>", $@"
  <ItemGroup>
    <PackageReference Include=""WalkingTec.Mvvm.Core"" Version=""{version}"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{modeldir}{Path.DirectorySeparatorChar}{modelns}.csproj", modelproj, Encoding.UTF8);
                }
                //修改dataproject
                var dataproj = File.ReadAllText($"{datadir}{Path.DirectorySeparatorChar}{datans}.csproj");
                if (dataproj.IndexOf($"{modelns}.csproj") < 0)
                {
                    dataproj = dataproj.Replace("</Project>", $@"
  <ItemGroup>
    <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{datadir}{Path.DirectorySeparatorChar}{datans}.csproj", dataproj, Encoding.UTF8);
                }
                //修改viewmodelproject
                var vmproj = File.ReadAllText($"{vmdir}{Path.DirectorySeparatorChar}{vmns}.csproj");
                if (vmproj.IndexOf($"{modelns}.csproj") < 0)
                {
                    vmproj = vmproj.Replace("</Project>", $@"
  <ItemGroup>
    <ProjectReference Include=""..\{modelns}\{modelns}.csproj"" />
  </ItemGroup >
</Project>
");
                    File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}{vmns}.csproj", vmproj, Encoding.UTF8);
                }
                var solution = File.ReadAllText($"{Directory.GetParent(MainDir)}{Path.DirectorySeparatorChar}{MainNs}.sln");
                if (solution.IndexOf($"{modelns}.csproj") < 0)
                {
                    Guid g1 = Guid.NewGuid();
                    Guid g2 = Guid.NewGuid();
                    Guid g3 = Guid.NewGuid();
                    solution = solution.Replace("EndProject", $@"EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{modelns}"", ""{modelns}\{modelns}.csproj"", ""{{{g1}}}""
EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{datans}"", ""{datans}\{datans}.csproj"", ""{{{g2}}}""
EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{vmns}"", ""{vmns}\{vmns}.csproj"", ""{{{g3}}}""
EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{testns}"", ""{testns}\{testns}.csproj"", ""{{{Guid.NewGuid()}}}""
EndProject
");
                    solution = solution.Replace(".Release|Any CPU.Build.0 = Release|Any CPU", $@".Release|Any CPU.Build.0 = Release|Any CPU
		{{{g1}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g1}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g1}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g1}}}.Release|Any CPU.Build.0 = Release|Any CPU
		{{{g2}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g2}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g2}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g2}}}.Release|Any CPU.Build.0 = Release|Any CPU
		{{{g3}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{{{g3}}}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{{{g3}}}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{{{g3}}}.Release|Any CPU.Build.0 = Release|Any CPU"        );
                    File.WriteAllText($"{Directory.GetParent(MainDir)}{Path.DirectorySeparatorChar}{MainNs}.sln", solution, Encoding.UTF8);
                }
            }

            else
            {
                var s1 = File.ReadAllText($"{Directory.GetParent(MainDir)}{Path.DirectorySeparatorChar}{MainNs}.sln");
                s1 = s1.Replace("EndProject", $@"EndProject
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{testns}"", ""{testns}\{testns}.csproj"", ""{{{Guid.NewGuid()}}}""
EndProject
");
                File.WriteAllText($"{Directory.GetParent(MainDir)}{Path.DirectorySeparatorChar}{MainNs}.sln", s1, Encoding.UTF8);
            }

            File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}appsettings.json", GetResource("Appsettings.txt")
                              .Replace("$cs$", CS ?? "")
                              .Replace("$dbtype$", DbType.ToString())
                              .Replace("$pagemode$", PageMode.ToString())
                              .Replace("$cookiepre$", CookiePre ?? "")
                              .Replace("$enablelog$", EnableLog.ToString().ToLower())
                              .Replace("$logexception$", LogExceptionOnly.ToString().ToLower())
                              .Replace("$rpp$", Rpp == null ? "" : Rpp.ToString())
                              .Replace("$filemode$", FileMode.ToString())
                              .Replace("$uploaddir$", UploadDir ?? ""), Encoding.UTF8
                              );
            File.WriteAllText($"{datadir}{Path.DirectorySeparatorChar}DataContext.cs", GetResource("DataContext.txt").Replace("$ns$", datans), Encoding.UTF8);

            File.WriteAllText($"{resourcedir}{Path.DirectorySeparatorChar}Program.zh.resx", GetResource("Resourcezh.txt"), Encoding.UTF8);
            File.WriteAllText($"{resourcedir}{Path.DirectorySeparatorChar}Program.en.resx", GetResource("Resourceen.txt"), Encoding.UTF8);
            if (UI == UIEnum.LayUI)
            {
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Controllers{Path.DirectorySeparatorChar}HomeController.cs", GetResource("HomeController.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Controllers{Path.DirectorySeparatorChar}LoginController.cs", GetResource("LoginController.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}_ViewStart.cshtml", GetResource("ViewStart.txt", "Mvc"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home{Path.DirectorySeparatorChar}Index.cshtml", GetResource("home.Index.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Login{Path.DirectorySeparatorChar}ChangePassword.cshtml", GetResource("home.ChangePassword.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home{Path.DirectorySeparatorChar}Layout.cshtml", GetResource("home.layout.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Login{Path.DirectorySeparatorChar}Login.cshtml", GetResource("home.Login.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home{Path.DirectorySeparatorChar}PIndex.cshtml", GetResource("home.PIndex.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Home{Path.DirectorySeparatorChar}FrontPage.cshtml", GetResource("home.FrontPage.txt", "Mvc").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}HomeVMs{Path.DirectorySeparatorChar}ChangePasswordVM.cs", GetResource("vms.ChangePasswordVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}HomeVMs{Path.DirectorySeparatorChar}IndexVM.cs", GetResource("vms.IndexVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{vmdir}{Path.DirectorySeparatorChar}HomeVMs{Path.DirectorySeparatorChar}LoginVM.cs", GetResource("vms.LoginVM.txt").Replace("$ns$", MainNs).Replace("$vmns$", vmns), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}Shared{Path.DirectorySeparatorChar}_Layout.cshtml", GetResource("layui.Layout.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Program.cs", GetResource("layui.Program.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Views{Path.DirectorySeparatorChar}_ViewImports.cshtml", GetResource("layui.ViewImports.txt", "Mvc"), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Areas{Path.DirectorySeparatorChar}_ViewImports.cshtml", GetResource("layui.ViewImports.txt", "Mvc"), Encoding.UTF8);
                File.WriteAllText($"{ExtraDir}{Path.DirectorySeparatorChar}alpine.Dockerfile", GetResource("alpine.Dockerfile.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8);
                File.WriteAllText($"{ExtraDir}{Path.DirectorySeparatorChar}Dockerfile", GetResource("Dockerfile.txt", "Mvc").Replace("$ns$", MainNs), Encoding.UTF8);
                UnZip("WalkingTec.Mvvm.Doc.SetupFiles.Mvc.layui.layui.zip", $"{MainDir}{Path.DirectorySeparatorChar}wwwroot");
            }
            if (UI == UIEnum.React)
            {
                Directory.CreateDirectory($"{MainDir}{Path.DirectorySeparatorChar}ClientApp");
                UnZip("WalkingTec.Mvvm.Doc.SetupFiles.Mvc.layui.layui.zip", $"{MainDir}{Path.DirectorySeparatorChar}wwwroot");
                UnZip("WalkingTec.Mvvm.Doc.SetupFiles.Spa.React.ClientApp.zip", $"{MainDir}{Path.DirectorySeparatorChar}ClientApp");
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}Program.cs", GetResource("Program.txt", "Spa").Replace("$ns$", MainNs), Encoding.UTF8);
                var config = File.ReadAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}global.config.tsx");
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}global.config.tsx", config.Replace("title: \"WalkingTec MVVM\",", $"title: \"{MainNs}\","), Encoding.UTF8);
                File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}setupProxy.js", $@"
const proxy = require('http-proxy-middleware');

module.exports = (app) => {{
    app.use(proxy('/api', {{
        target: 'http://localhost:{Port}/',
        changeOrigin: true,
        logLevel: ""debug""
    }}));
}};
", Encoding.UTF8);
            }

            if (File.Exists($"{MainDir}{Path.DirectorySeparatorChar}Startup.cs"))
            {
                File.Delete($"{MainDir}{Path.DirectorySeparatorChar}Startup.cs");
            }
        }