/// <summary> /// Handles library project specific matters. /// </summary> /// <param name="baseNamespace">Base namespace in project.</param> /// <param name="name">Name of project.</param> /// <param name="includes">Files to be included.</param> /// <param name="contents">Content to be included.</param> /// <param name="files">All files in project.</param> /// <param name="nugets">Nugets to be referenced.</param> /// <param name="imports">Projects to be referenced.</param> /// <returns></returns> public static AssemblyBase MakeLibraryProject(string baseNamespace, string name, List <IGenerableFile> includes, List <ContentInfo> contents, List <IGenerableFile> files, List <PackageConfigInfo> nugets, List <AssemblyBase> imports) { AssemblyBase library = new LibraryAssemblyFileGenerator(new List <IGenerableFile>(), new AssemblyInfo { Name = name, ProjectFileRelativePath = name }); library.AssemblyInfo.Contents.AddRange(contents); AssemblyInfoModelGenerator assemblyInfo = new AssemblyInfoModelGenerator(new GenerationInfo("AssemblyInfo.cs", Path.Combine(library.GenerationInfo.RelativePathFolder, "Properties"), new AssemblyInfoTemplate(), true), library.AssemblyInfo); PackagesConfigGenerator packagesConfig = new PackagesConfigGenerator(nugets, new GenerationInfo("packages.config", library.GenerationInfo.RelativePathFolder, new LibraryPackageConfigTemplate(), true)); files.Add(library); files.Add(packagesConfig); files.Add(assemblyInfo); library.AssemblyInfo.AssemblyImports.AddRange(imports); library.AssemblyInfo.FilesToCompile.AddRange(includes); library.AssemblyInfo.FilesToCompile.Add(assemblyInfo); library.AssemblyInfo.Packages.AddRange(nugets); library.AssemblyInfo.IncludeOnlys.Add(packagesConfig.GenerationInfo.FileName); library.AssemblyInfo.ProjectType = Guid.Parse("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"); library.AssemblyInfo.UniqueProjectId = Guid.NewGuid(); return(library); }
/// <summary> /// Handles web api project specific matters. /// </summary> /// <param name="baseNamespace">Base namespace in project.</param> /// <param name="name">Name of project.</param> /// <param name="includes">Files to be included.</param> /// <param name="contents">Content to be included.</param> /// <param name="files">All files in project.</param> /// <param name="nugets">Nugets to be referenced.</param> /// <param name="imports">Projects to be referenced.</param> /// <returns></returns> public static AssemblyBase MakeWebApiProject(string baseNamespace, string name, List <IGenerableFile> includes, List <ContentInfo> contents, List <IGenerableFile> files, List <PackageConfigInfo> nugets, List <AssemblyBase> imports) { AssemblyBase apiProject = new WebApiAssemblyFileGenerator(new List <IGenerableFile>(), new AssemblyInfo { Name = name, ProjectFileRelativePath = name }); apiProject.AssemblyInfo.ProjectType = Guid.Parse("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"); apiProject.AssemblyInfo.UniqueProjectId = Guid.NewGuid(); apiProject.AssemblyInfo.Contents.AddRange(contents); AssemblyInfoModelGenerator apiLayerAssemblyInfoModel = new AssemblyInfoModelGenerator(new GenerationInfo("AssemblyInfo.cs", Path.Combine(apiProject.GenerationInfo.RelativePathFolder, "Properties"), new AssemblyInfoTemplate(), true), apiProject.AssemblyInfo); GlobalAsaxGenerator globalAsax = new GlobalAsaxGenerator(name, "Global", new GenerationInfo("Global.asax", apiProject.GenerationInfo.RelativePathFolder, new GlobalAsaxTemplate(), true), baseNamespace); PackagesConfigGenerator packagesConfig = new PackagesConfigGenerator(nugets, new GenerationInfo("packages.config", apiProject.GenerationInfo.RelativePathFolder, new WebApiPackageConfigTemplate(), true)); WebConfigGenerator webConfig = new WebConfigGenerator(name, "Web", new GenerationInfo("Web.config", apiProject.GenerationInfo.RelativePathFolder, new WebConfigTemplate(), false)); WebDebugConfigGenerator webDebugConfig = new WebDebugConfigGenerator(name, "Web.Debug", new GenerationInfo("Web.Debug.config", apiProject.GenerationInfo.RelativePathFolder, new WebDebugConfigTemplate(), false)); WebReleaseConfigGenerator webReleaseConfig = new WebReleaseConfigGenerator(name, "Web.Release", new GenerationInfo("Web.Release.config", apiProject.GenerationInfo.RelativePathFolder, new WebReleaseConfigTemplate(), false)); WebApiConfigGenerator webApiConfig = new WebApiConfigGenerator(name, "WebApiConfig", new GenerationInfo("WebApiConfig.cs", Path.Combine(apiProject.GenerationInfo.RelativePathFolder, "App_Start"), new WebApiConfigTemplate(), true)); files.Add(apiProject); files.Add(globalAsax); files.Add(packagesConfig); files.Add(webConfig); files.Add(webDebugConfig); files.Add(webReleaseConfig); files.Add(webApiConfig); files.Add(apiLayerAssemblyInfoModel); apiProject.AssemblyInfo.AssemblyImports.AddRange(imports); apiProject.AssemblyInfo.Packages.AddRange(nugets); apiProject.AssemblyInfo.FilesToCompile.AddRange(includes); apiProject.AssemblyInfo.FilesToCompile.Add(apiLayerAssemblyInfoModel); apiProject.AssemblyInfo.FilesToCompile.Add(globalAsax); apiProject.AssemblyInfo.FilesToCompile.Add(packagesConfig); apiProject.AssemblyInfo.FilesToCompile.Add(webConfig); apiProject.AssemblyInfo.FilesToCompile.Add(webDebugConfig); apiProject.AssemblyInfo.FilesToCompile.Add(webReleaseConfig); apiProject.AssemblyInfo.FilesToCompile.Add(webApiConfig); return(apiProject); }
private void WriteProjectNuGetPackages(XmlWriter xw, Project project) { if (project.NuGetPackages.Count <= 0) { return; } xw.WriteStartElement("ItemGroup"); foreach (var package in project.NuGetPackages) { WriteNuGetPackage(xw, package); } xw.WriteEndElement(); var pkgConf = new PackagesConfigGenerator(_targetFrameworkMonikerStringBuilder).Generate(project.NuGetPackages, project.TargetFrameworks); project.AddFile(pkgConf); }