/// <summary> /// Create .net project /// </summary> /// <param name="type"></param> /// <param name="lang"></param> /// <param name="name"></param> /// <param name="dir"></param> /// <param name="framework"></param> public ResultLog CreateProject(ProjectType type, ProjectLanguage lang, string name, string dir, ProjectFramework framework = ProjectFramework.Default) { string typeStr = ProjectTypeAsStr(type); string frameworkStr = String.Empty; string langStr = "--language " + LanguageAsStr(lang); string nameStr = "--name " + InQuotes(name); string outputStr = "--output " + InQuotes(dir); //framework arg if (framework != ProjectFramework.Default && ( typeStr == "classlib" || typeStr == "web" || typeStr == "wpf" || typeStr == "console")) { frameworkStr = "--framework " + FrameworkAsStr(framework); } string cmd = "dotnet new " + typeStr + " " + nameStr + " " + outputStr + " " + langStr; if (frameworkStr != String.Empty) { cmd += " " + frameworkStr; } //execute return(new ResultLog(Caller.ExecuteCommand(cmd))); }
public IFramework GetFrameworkService(ProjectFramework framework) { return(framework switch { ProjectFramework.Dotnet => _serviceProvider.GetRequiredService <IDotnet>(), ProjectFramework.Node => _serviceProvider.GetRequiredService <INode>(), ProjectFramework.RubyOnRails => _serviceProvider.GetRequiredService <IRubyOnRails>(), ProjectFramework.Django => _serviceProvider.GetRequiredService <IDjango>(), ProjectFramework.Any => throw new ArgumentException($"Cannot get framework service for project framework type of {framework}", nameof(framework)), _ => throw new NotImplementedException($"There is no implementation for framework of type {framework}"), });
public void GetAllProjectFrameworkTypes_returns_every_type_of_project_framework_except_Any() { var service = CreateService(null); var allProjectFrameworkTypes = service.GetAllProjectFrameworkTypes(); foreach (var enumValue in Enum.GetValues(typeof(ProjectFramework))) { ProjectFramework projectFramework = (ProjectFramework)enumValue; if (projectFramework != ProjectFramework.Any) { Assert.Contains(projectFramework, allProjectFrameworkTypes); allProjectFrameworkTypes.Remove(projectFramework); } } Assert.Empty(allProjectFrameworkTypes); }
/// <summary> /// Publish .net project /// </summary> /// <param name="projFile"></param> /// <param name="outDir"></param> /// <param name="selfContained"></param> /// <param name="framework"></param> /// <param name="withDependencies"></param> /// <param name="verb"></param> /// <returns></returns> public ResultLog PublishProject(string projFile, string outDir, BuildConfiguration configuration, string platform, bool selfContained = false, ProjectFramework framework = ProjectFramework.Default, bool withDependencies = true, BuildVerbosity verb = BuildVerbosity.Minimal) { string outputStr = "--output " + InQuotes(outDir); string configurationStr = "--configuration " + ConfigurationAsStr(configuration); string frameworkStr = "--framework " + FrameworkAsStr(framework); string runtimeStr = "--runtime " + platform; string verbosityStr = "--verbosity " + VerbosityAsStr(verb); string nodependStr = withDependencies ? "" : " --no-dependencies"; string selfcontStr = "--self-contained " + BoolAsStr(selfContained); string cmd = "dotnet publish " + InQuotes(projFile) + " " + outputStr + " " + configurationStr + " " + verbosityStr + " " + runtimeStr + nodependStr + " " + selfcontStr; if (framework != ProjectFramework.Default) { cmd += " " + frameworkStr; } //execute return(new ResultLog(Caller.ExecuteCommand(cmd))); }
public void Returns_framework_service_for_every_ProjectFramework_except_Any() { var service = CreateService(); foreach (var enumValue in Enum.GetValues(typeof(ProjectFramework))) { ProjectFramework projectFramework = (ProjectFramework)enumValue; if (projectFramework != ProjectFramework.Any) { try { Assert.IsAssignableFrom <IFramework>(service.GetFrameworkService(projectFramework)); } catch (Exception e) { _console.WriteLine($"Failed to get framework service for framework type {projectFramework}. Details:\n{e}"); throw; } } } }
private string FrameworkAsStr(ProjectFramework framework) { if (framework == ProjectFramework.NetCoreApp3_0) { return("netcoreapp3.0"); } else if (framework == ProjectFramework.NetCoreApp3_1) { return("netcoreapp3.1"); } else if (framework == ProjectFramework.NetStandard2_1) { return("netstandard2.1"); } else if (framework == ProjectFramework.NetStandard2_0) { return("netstandard2.0"); } else { throw new NotImplementedException("Unknown framework"); } }
public void Delete(Guid project_id, Guid framework_id) { try { if (!_framework.Any(f => f.Id.Equals(framework_id))) { throw NotFound(framework_id, "framework id"); } ProjectFramework project_framework = _projectFramework.GetOne(pf => pf.FrameworkId.Equals(framework_id) && pf.ProjectId.Equals(project_id)); if (project_framework == null) { throw BadRequest("Do not have this framework refer to the project!"); } _projectFramework.Remove(project_framework); SaveChanges(); } catch (Exception e) { throw e is RequestException ? e : _errorHandler.WriteLog("An error occurred while delete a project framework!", e, DateTime.Now, "Server", "Service_ProjectFramework_Delete"); } }
public ExtraAnalysisDetails(string filePath, ProjectFramework framework) { // All keys lowercase for easier searching this.Add("filepath", filePath); this.Add("framework", framework); }
public ProjectViewModel(Project project, IEnumerable <string> files) { ThreadHelper.ThrowIfNotOnUIThread(); Project = project; Name = Path.GetFileNameWithoutExtension(project.UniqueName); FolderName = Path.GetDirectoryName(project.UniqueName); var properties = ThreadHelper.JoinableTaskFactory.Run(async() => await Project.GetEvaluatedPropertiesAsync()); properties.TryGetValue("TargetPath", out var targetPath); OutputFullPath = targetPath ?? project.GetFullOutputPath(); ProjectFramework = project.GetFrameworkString(); ProjectType = project.GetOutputType(); ProjectLang = project.GetLanguageName(); Files = new ObservableCollection <ProjectFileViewModel>(files.Select(p => new ProjectFileViewModel(p)).ToList()); properties.TryGetValue("TargetFileName", out var targetFileName); if (!string.IsNullOrEmpty(targetFileName)) { FileToProtect = targetFileName; return; } if (!string.IsNullOrEmpty(targetPath)) { var fileName = Path.GetFileName(targetPath); if (string.IsNullOrEmpty(fileName)) { FileToProtect = targetFileName; return; } } //throw new Exception("Can't find output file name."); //TODO: Remove: var outPutPaths = project.GetBuildOutputFilePaths(new BuildOutputFileTypes { Built = true, ContentFiles = false, Documentation = false, LocalizedResourceDlls = false, SourceFiles = false, Symbols = false, XmlSerializer = false }); var outPutFiles = outPutPaths.Select(Path.GetFileName); if (string.IsNullOrEmpty(ProjectType)) { FileToProtect = outPutFiles.FirstOrDefault(x => x.EndsWith(".dll") || x.EndsWith(".exe")); } else if (ProjectType.ToLower().Contains("winexe")) { FileToProtect = ProjectFramework.ToLower().Contains("framework") ? outPutFiles.FirstOrDefault(x => x.EndsWith(".exe")) : outPutFiles.FirstOrDefault(x => x.EndsWith(".dll")); } else if (ProjectType.ToLower().Contains("library")) { FileToProtect = outPutFiles.FirstOrDefault(x => x.EndsWith(".dll")); } else { FileToProtect = outPutFiles.FirstOrDefault(x => x.EndsWith(".dll") || x.EndsWith(".exe")); } }
public static ExtraAnalysisDetails Create(ProjectFramework framework = ProjectFramework.Unknown) { return(new ExtraAnalysisDetails( "TestFile.xaml", framework)); }