void EditionKeyboard() { Grid grid = (Grid)target; #region Grid editing shortcuts if (!Event.current.shift) { if (Event.current.type == EventType.keyDown) { if ((Event.current.character == 'a' || Event.current.character == 'A') && grid.Edition != 1) { ChangeEdition(1, target); } else if ((Event.current.character == 's' || Event.current.character == 'S') && grid.Edition != 2) { ChangeEdition(2, target); } else if ((Event.current.character == 'd' || Event.current.character == 'D') && grid.Edition != 3) { ChangeEdition(3, target); } else if ((Event.current.character == 'v' || Event.current.character == 'V') && grid.Edition != 3) { ChangeEdition(0, target); } else if (Event.current.character == 'c' || Event.current.character == 'C') { if (grid.EditionType == 1) { ChangeEditionType(2, target); } else if (grid.EditionType == 2) { ChangeEditionType(1, target); } } else if (Event.current.character == 'z' || Event.current.character == 'Z') { ChangeEdition(4, target); PathUtility.UpdatePathLines(target); } else if (Event.current.character == 'x' || Event.current.character == 'X') { ChangeEdition(5, target); PathUtility.UpdatePathLines(target); } } } #endregion #region Increase/ Decrease grid shortcuts if (Event.current.type == EventType.keyDown) { if (Event.current.character == 'q' || Event.current.character == 'Q') { GridEditorUtility.IncreaseGrid(target, 1); } else if (Event.current.character == 'w' || Event.current.character == 'W') { GridEditorUtility.IncreaseGrid(target, 2); } else if (Event.current.character == 'e' || Event.current.character == 'E') { GridEditorUtility.IncreaseGrid(target, 3); } else if (Event.current.character == 'r' || Event.current.character == 'R') { GridEditorUtility.IncreaseGrid(target, 4); } else if (Event.current.character == 'y' || Event.current.character == 'Y') { GridEditorUtility.DecreaseGrid(target, 1); } else if (Event.current.character == 'u' || Event.current.character == 'U') { GridEditorUtility.DecreaseGrid(target, 2); } else if (Event.current.character == 'i' || Event.current.character == 'I') { GridEditorUtility.DecreaseGrid(target, 3); } else if (Event.current.character == 'o' || Event.current.character == 'O') { GridEditorUtility.DecreaseGrid(target, 4); } } #endregion }
private void AssertLockFileItemPath(string path, LockFileItem item) { Assert.NotNull(item); Assert.Equal(path, PathUtility.GetPathWithForwardSlashes(item.Path)); }
private static void InitializeProjectDependencies( LockFile assetsFile, IDictionary <NuGetFramework, HashSet <LibraryDependency> > dependenciesByFramework, IDictionary <string, string> projectRefToVersionMap, ISet <NuGetFramework> frameworkWithSuppressedDependencies) { // From the package spec, all we know is each absolute path to the project reference the the target // framework that project reference applies to. if (assetsFile.PackageSpec.RestoreMetadata == null) { return; } // Using the libraries section of the assets file, the library name and version for the project path. var projectPathToLibraryIdentities = assetsFile .Libraries .Where(library => library.MSBuildProject != null) .ToLookup( library => Path.GetFullPath(Path.Combine( Path.GetDirectoryName(assetsFile.PackageSpec.RestoreMetadata.ProjectPath), PathUtility.GetPathWithDirectorySeparator(library.MSBuildProject))), library => new PackageIdentity(library.Name, library.Version), PathUtility.GetStringComparerBasedOnOS()); // Consider all of the project references, grouped by target framework. foreach (var framework in assetsFile.PackageSpec.RestoreMetadata.TargetFrameworks) { var target = assetsFile.GetTarget(framework.FrameworkName, runtimeIdentifier: null); if (target == null || frameworkWithSuppressedDependencies.Contains(framework.FrameworkName)) { continue; } HashSet <LibraryDependency> dependencies; if (!dependenciesByFramework.TryGetValue(framework.FrameworkName, out dependencies)) { dependencies = new HashSet <LibraryDependency>(); dependenciesByFramework[framework.FrameworkName] = dependencies; } // For the current target framework, create a map from library identity to library model. This allows // us to be sure we have picked the correct library (name and version) for this target framework. var libraryIdentityToTargetLibrary = target .Libraries .ToLookup(library => new PackageIdentity(library.Name, library.Version)); foreach (var projectReference in framework.ProjectReferences) { var libraryIdentities = projectPathToLibraryIdentities[projectReference.ProjectPath]; var targetLibrary = libraryIdentities .Select(identity => libraryIdentityToTargetLibrary[identity].FirstOrDefault()) .FirstOrDefault(library => library != null); if (targetLibrary == null) { continue; } var versionToUse = new VersionRange(targetLibrary.Version); // Use the project reference version obtained at build time if it exists, otherwise fallback to the one in assets file. if (projectRefToVersionMap.TryGetValue(projectReference.ProjectPath, out var projectRefVersion)) { versionToUse = VersionRange.Parse(projectRefVersion, allowFloating: false); } // TODO: Implement <TreatAsPackageReference>false</TreatAsPackageReference> // https://github.com/NuGet/Home/issues/3891 // // For now, assume the project reference is a package dependency. var projectDependency = new LibraryDependency { LibraryRange = new LibraryRange( targetLibrary.Name, versionToUse, LibraryDependencyTarget.All), IncludeType = projectReference.IncludeAssets & ~projectReference.ExcludeAssets, SuppressParent = projectReference.PrivateAssets }; PackCommandRunner.AddLibraryDependency(projectDependency, dependencies); } } }
public override async Task AddReferenceAsync(string referencePath) { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var name = Path.GetFileNameWithoutExtension(referencePath); try { EnvDTEProjectUtility.GetAssemblyReferences(VsProjectAdapter.Project).AddFromFile(PathUtility.GetAbsolutePath(ProjectFullPath, referencePath)); // Always create a refresh file. Vs does this for us in most cases, however for GACed binaries, it resorts to adding a web.config entry instead. // This may result in deployment issues. To work around ths, we'll always attempt to add a file to the bin. RefreshFileUtility.CreateRefreshFile(ProjectFullPath, PathUtility.GetAbsolutePath(ProjectFullPath, referencePath), this); NuGetProjectContext.Log(ProjectManagement.MessageLevel.Debug, $"Added reference '{name}' to project:'{ProjectName}' "); } catch (Exception e) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings.FailedToAddReference, name), e); } }
private static bool IsUnderAppCode(string path) { return(PathUtility.EnsureTrailingSlash(path).StartsWith(AppCodeFolder + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)); }
private static string RebasePath(string path, string oldBaseDirectory, string newBaseDirectory) { path = Path.IsPathRooted(path) ? PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(oldBaseDirectory), path) : path; return(Path.Combine(newBaseDirectory, path)); }
public void PreProcess() { PathUtility.EnsureEmptyDirectory(this.buildSettings.TempGameDefinitionBuildPath); }
/// <summary> /// Execute the task /// </summary> /// <returns>true if task succeeded, false otherwise</returns> public void Execute() { if (!runningFromCommandLine) { string arguments = Parser.Arguments; Output.Message(MessageImportance.Low, Parser.CommandName + (arguments.Length == 0 ? "" : " " + Parser.Arguments)); } // If the help option appears anywhere, just show the help if (this.ShowHelp) { Output.Message(Parser.LogoBanner); Output.Message(Parser.Usage); Output.Message(""); return; } // From this point on assume a bad exit code this.ExitCode = 1; // At this point, we need a source file (the default argument) if (this.ScriptPath == null) { Output.Error(CsrResources.NoScriptSpecified); return; } // Need a zero length array if no command line arguments given if (this.Arguments == null) { this.Arguments = new string[0]; } // Before we fully qualify the file record whether it had any full or relative path part bool justFilenameGiven = this.ScriptPath.IsFilenameOnly; if (this.ScriptPath.File == String.Empty) { Output.Error(CsrResources.NoEmptyFileName); return; } else if (this.ScriptPath.HasWildcards) { Output.Error(CsrResources.NoScriptWildcards); return; } if (this.ScriptPath.Extension == String.Empty) { this.ScriptPath = new ParsedPath(this.ScriptPath.VolumeDirectoryAndFile + ".csr", PathType.File); } // Fully qualify the path based on current directory this.ScriptPath = this.ScriptPath.MakeFullPath(); // Check that the source exists, and optionally search for it in the PATH if (!File.Exists(this.ScriptPath)) { if (this.SearchSystemPath && justFilenameGiven) { IList <ParsedPath> found = PathUtility.FindFileInPaths( new ParsedPathList(System.Environment.GetEnvironmentVariable("PATH"), PathType.Directory), this.ScriptPath.FileAndExtension); if (found.Count > 0) { this.ScriptPath = new ParsedPath(found[0], PathType.File); if (this.DebugMessages) { Output.Message(MessageImportance.Low, CsrResources.ScriptFoundInPath(this.ScriptPath.FileAndExtension, this.ScriptPath.VolumeAndDirectory)); } } else { Output.Error(CsrResources.ScriptNotFoundInDirectoryOrPath(this.ScriptPath.FileAndExtension, this.ScriptPath.VolumeAndDirectory)); return; } } else { Output.Error(CsrResources.ScriptNotFound(this.ScriptPath)); return; } } // Set publicly visible script path (in this AppDomain) ScriptEnvironment.ScriptPath = this.ScriptPath; // Now we have a valid script file, go an extract the details ScriptInfo scriptInfo = null; try { scriptInfo = ScriptInfo.GetScriptInfo(this.ScriptPath); } catch (ScriptInfoException e) { Output.Error(e.Message); return; } IList <RuntimeInfo> runtimeInfos = RuntimeInfo.GetInstalledRuntimes(); RuntimeInfo runtimeInfo = null; // Check to see that the scripts requested CLR & Fx are available. for (int i = 0; i < runtimeInfos.Count; i++) { if (runtimeInfos[i].ClrVersion == scriptInfo.ClrVersion && runtimeInfos[i].FxVersion == scriptInfo.FxVersion) { runtimeInfo = runtimeInfos[i]; break; } } if (runtimeInfo == null) { Output.Error(CsrResources.ScriptsRequiredRuntimeAndFrameworkNotInstalled(scriptInfo.ClrVersion, scriptInfo.FxVersion)); return; } IList <ParsedPath> references; try { references = ScriptInfo.GetFullScriptReferencesPaths(scriptPath, scriptInfo, runtimeInfo); } catch (ScriptInfoException e) { Output.Error(e.Message); return; } if (this.DebugMessages) { Output.Message(MessageImportance.Low, CsrResources.RuntimeVersion( ProcessUtility.IsThis64BitProcess ? CsrResources.WordSize64 : CsrResources.WordSize32, RuntimeEnvironment.GetSystemVersion().ToString())); Output.Message(MessageImportance.Low, CsrResources.ClrInstallPath(runtimeInfo.ClrInstallPath)); Output.Message(MessageImportance.Low, CsrResources.NetFxInstallPath(runtimeInfo.FxInstallPath)); Output.Message(MessageImportance.Low, CsrResources.NetFxReferenceAssemblyPath(runtimeInfo.FxReferenceAssemblyPath)); Output.Message(MessageImportance.Low, CsrResources.TemporaryFileDirectory(TemporaryFileDirectory)); foreach (var reference in references) { Output.Message(MessageImportance.Low, CsrResources.Referencing(reference)); } } try { IDictionary <string, string> providerOptions = new Dictionary <string, string>(); // Setting the compiler version option should only be done under Fx 3.5 otherwise the option should be not present if (scriptInfo.FxVersion == "3.5") { providerOptions.Add("CompilerVersion", "v" + scriptInfo.FxVersion); } CodeDomProvider provider = new CSharpCodeProvider(providerOptions); CompilerParameters parms = new CompilerParameters(); // NOTE: When adding compiler options, don't forget to always add a space at end... <sigh/> StringBuilder compilerOptions = new StringBuilder(); foreach (var reference in references) { compilerOptions.AppendFormat("/r:\"{0}\" ", reference); } parms.CompilerOptions = compilerOptions.ToString(); parms.GenerateExecutable = true; // This doesn't mean generate a file on disk, it means generate an .exe not a .dll if (StackTraces) { if (!Directory.Exists(TemporaryFileDirectory)) { Directory.CreateDirectory(this.TemporaryFileDirectory); } parms.OutputAssembly = TemporaryFileDirectory.VolumeAndDirectory + ScriptPath.File + ".exe"; parms.GenerateInMemory = false; parms.IncludeDebugInformation = true; parms.CompilerOptions += "/optimize- "; } else { parms.GenerateInMemory = true; parms.CompilerOptions += "/optimize+ "; } if (this.AllowUnsafeCode) { parms.CompilerOptions += "/unsafe+ "; } if (DebugMessages) { Output.Message(MessageImportance.Low, "Compiling script file '{0}'", this.ScriptPath); } CompilerResults results = provider.CompileAssemblyFromFile(parms, this.ScriptPath); if (results.Errors.Count > 0) { foreach (CompilerError error in results.Errors) { Console.Error.WriteLine( CsrResources.ErrorLine(error.FileName, error.Line, error.Column, error.ErrorNumber, error.ErrorText)); } return; } else { // Take the compiled assembly and invoke it in this appdomain. object ret = null; ScriptEnvironment.FullyQualifiedReferences = references; AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnAssemblyResolve); // Get information about the entry point MethodInfo mainMethod = results.CompiledAssembly.EntryPoint; ParameterInfo[] mainParams = mainMethod.GetParameters(); Type returnType = mainMethod.ReturnType; try { if (returnType == typeof(void)) { if (mainParams.Length > 0) { mainMethod.Invoke(null, new object[1] { this.Arguments }); } else { mainMethod.Invoke(null, null); } } else { if (mainParams.Length > 0) { ret = mainMethod.Invoke(null, new object[1] { this.Arguments }); } else { ret = mainMethod.Invoke(null, null); } } } catch (Exception ex) // Catch script errors { // When catching a script error here, the actual script exception will be the inner exception Output.Error(String.Format( CsrResources.ExceptionFromScript(ex.InnerException != null ? ex.InnerException.Message : ex.Message))); if (this.StackTraces && ex.InnerException != null) { Output.Error(ex.InnerException.StackTrace); } return; } if (ret != null && returnType == typeof(int)) { this.ExitCode = (int)ret; return; } } } catch (Exception ex) // Catch compilation exceptions { string message = CsrResources.ExceptionDuringCompile + ex.Message; if (ex.InnerException != null) { message += ex.InnerException.Message; } Output.Error(message); return; } ExitCode = 0; return; }
public void GenerateAsm() { // Build a command per assembly to generate the asm output. foreach (var assembly in _assemblyInfoList) { string fullPathAssembly = Path.Combine(assembly.Path, assembly.Name); if (!File.Exists(fullPathAssembly)) { // Assembly not found. Produce a warning and skip this input. Console.WriteLine("Skipping. Assembly not found: {0}", fullPathAssembly); continue; } List <string> commandArgs = new List <string>() { fullPathAssembly }; // Set platform assermbly path if it's defined. if (_platformPaths.Count > 0) { commandArgs.Insert(0, "/Platform_Assemblies_Paths"); commandArgs.Insert(1, String.Join(" ", _platformPaths)); } Command generateCmd = Command.Create( _executablePath, commandArgs); // Pick up ambient COMPlus settings. foreach (string envVar in Environment.GetEnvironmentVariables().Keys) { if (envVar.IndexOf("COMPlus_") == 0) { string value = Environment.GetEnvironmentVariable(envVar); if (this.verbose) { Console.WriteLine("Incorporating ambient setting: {0}={1}", envVar, value); } generateCmd.EnvironmentVariable(envVar, value); } } // Set up environment do disasm. generateCmd.EnvironmentVariable("COMPlus_NgenDisasm", "*"); generateCmd.EnvironmentVariable("COMPlus_NgenUnwindDump", "*"); generateCmd.EnvironmentVariable("COMPlus_NgenEHDump", "*"); generateCmd.EnvironmentVariable("COMPlus_JitDiffableDasm", "1"); if (this.doGCDump) { generateCmd.EnvironmentVariable("COMPlus_NgenGCDump", "*"); } if (this.verbose) { Console.WriteLine("Running: {0} {1}", _executablePath, String.Join(" ", commandArgs)); } CommandResult result; if (_rootPath != null) { // Generate path to the output file var assemblyFileName = Path.ChangeExtension(assembly.Name, ".dasm"); var path = Path.Combine(_rootPath, assembly.OutputPath, assemblyFileName); PathUtility.EnsureParentDirectory(path); // Redirect stdout/stderr to disasm file and run command. using (var outputStream = System.IO.File.Create(path)) { using (var outputStreamWriter = new StreamWriter(outputStream)) { // Forward output and error to file. generateCmd.ForwardStdOut(outputStreamWriter); generateCmd.ForwardStdErr(outputStreamWriter); result = generateCmd.Execute(); } } } else { // By default forward to output to stdout/stderr. generateCmd.ForwardStdOut(); generateCmd.ForwardStdErr(); result = generateCmd.Execute(); } if (result.ExitCode != 0) { Console.WriteLine("Error running {0} on {1}", _executablePath, fullPathAssembly); _errorCount++; } } }
public NLogHandle(Logger log) { LogManager.Configuration = new XmlLoggingConfiguration(PathUtility.GetApplicationPath(CommonCode.ConfigName.NLogConfig)); this._log = log; }
public override void Prewarm() { base.Prewarm(); UnityAPI.Await ( () => { if (PeekPlugin.Configuration.createPrimitives) { var primitivePaths = EditorMainMenu .GetSubmenus("GameObject") .Where(mi => !(createMenuBlacklist.Contains(mi) || PeekPlugin.Configuration.createMenuBlacklist.Contains(mi))) .ToArray(); var primitiveFolders = HashSetPool <string> .New(); foreach (var primitivePath in primitivePaths) { var primitiveOption = CreateGameObjectOption.Primitive(primitivePath); var primitiveFolder = primitiveOption.primitiveFolder; primitiveOptions.Add(primitiveOption); if (primitiveFolder != "GameObject" && !primitiveFolders.Contains(primitiveFolder)) { primitiveFolderOptions.Add(new MenuFolderOption(primitiveFolder)); primitiveFolders.Add(primitiveFolder); } } primitiveFolders.Free(); } if (PeekPlugin.Configuration.createPrefabs) { foreach (var prefabResult in AssetDatabaseUtility.FindAssets("t:prefab").Where(IncludeAsset)) { assetOptions.Add(CreateGameObjectOption.Prefab(prefabResult)); } } if (PeekPlugin.Configuration.createModels) { foreach (var modelResult in AssetDatabaseUtility.FindAssets("t:model").Where(IncludeAsset)) { assetOptions.Add(CreateGameObjectOption.Model(modelResult)); } } if (PeekPlugin.Configuration.createSprites) { foreach (var spriteResult in AssetDatabaseUtility.FindAssets("t:sprite").Where(IncludeAsset)) { assetOptions.Add(CreateGameObjectOption.Sprite(spriteResult)); } } var assetFolders = HashSetPool <string> .New(); foreach (var assetOption in assetOptions) { var assetFolder = assetOption.assetFolder; while (!string.IsNullOrEmpty(assetFolder)) { if (!assetFolders.Contains(assetFolder)) { assetFolderOptions.Add(new AssetFolderOption(assetFolder)); assetFolders.Add(assetFolder); } else { break; } assetFolder = PathUtility.NaiveParent(assetFolder); } } assetFolders.Free(); } ); }
private bool MappingsTargetPathIsFile(string targetPath) { var normalizedTargetPath = PathUtility.GetPathWithDirectorySeparator(targetPath); return(normalizedTargetPath[normalizedTargetPath.Length - 1] != Path.DirectorySeparatorChar); }
internal List <InstalledPackage> GetInstalledPackages() { var installedPackages = new List <InstalledPackage>(); var targetLibraries = GetSupportedTargetFrameworkLibraries().ToList(); foreach (var targetLibrary in targetLibraries) { var packageFolder = GetFolderForLibrary(targetLibrary); var dependencies = targetLibrary.Dependencies.Select(x => new PackageRequest { Id = x.Id, VersionsRange = x.VersionRange.OriginalString }); var library = _lockFile.GetLibrary(targetLibrary.Name, targetLibrary.Version); var contentFiles = library.Files.Select(x => new ContentFile { PhysicalPath = Path.Combine(packageFolder, PathUtility.GetPathWithDirectorySeparator(x)), InPackagePath = PathUtility.GetPathWithDirectorySeparator(x) }).ToList(); installedPackages.Add(new InstalledPackage(library.Name, library.Version.Version.ToString(), dependencies, packageFolder, contentFiles)); } var sortedPackages = SortInstalledPackagesByDependencies(targetLibraries, installedPackages); sortedPackages.Add(GetProjectAsInstalledPackage()); return(sortedPackages); }
internal List <string> GetRuntimeAssembliesFromPackages() { return(GetSupportedTargetFrameworkLibraries().Where(x => x.Type == LibraryType.Package) .Select(targetLibrary => new { PackageFolder = GetFolderForPackageLibraray(targetLibrary), targetLibrary.RuntimeAssemblies }) .SelectMany(targetLibrary => targetLibrary.RuntimeAssemblies.Select(libFile => Path.Combine(targetLibrary.PackageFolder, PathUtility.GetPathWithDirectorySeparator(libFile.Path)))) .Where(libFile => Path.GetExtension(libFile) == ".dll") .ToList()); }
private static string ConvertToDestinationPath(string path, string src, string dest) { var relativePath = PathUtility.MakeRelativePath(src, path); return(Path.Combine(dest ?? string.Empty, relativePath)); }
public static ArgumentsRule DefaultToCurrentDirectory(this ArgumentsRule rule) => rule.With(defaultValue: () => PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()));
private IEnumerable <string> EnumerateFilesWithRelativePath(string testProjectDirectory) { return (Directory.EnumerateFiles(testProjectDirectory, "*", SearchOption.AllDirectories) .Select(file => PathUtility.GetRelativePath(testProjectDirectory, file))); }
/// <summary> /// Retrieve the full project closure including the root project itself. /// </summary> /// <remarks>Results are not sorted in any form.</remarks> public IReadOnlyList <PackageSpec> GetClosure(string rootUniqueName) { if (rootUniqueName == null) { throw new ArgumentNullException(nameof(rootUniqueName)); } var projectsByUniqueName = _projects .ToDictionary(t => t.Value.RestoreMetadata.ProjectUniqueName, t => t.Value, PathUtility.GetStringComparerBasedOnOS()); var closure = new List <PackageSpec>(); var added = new SortedSet <string>(PathUtility.GetStringComparerBasedOnOS()); var toWalk = new Stack <PackageSpec>(); // Start with the root toWalk.Push(GetProjectSpec(rootUniqueName)); while (toWalk.Count > 0) { var spec = toWalk.Pop(); if (spec != null) { // Add every spec to the closure closure.Add(spec); // Find children foreach (var projectName in GetProjectReferenceNames(spec, projectsByUniqueName)) { if (added.Add(projectName)) { toWalk.Push(GetProjectSpec(projectName)); } } } } return(closure); }
private static void BuildPlayer() { Prefs.isBuilding = true; // ビルド設定適用. ApplyBuildSettings(true); // 出力先. var directory = string.Empty; directory = GetExportDirectory(BatchMode); if (string.IsNullOrEmpty(directory)) { return; } directory = PathUtility.Combine(directory, EditorUserBuildSettings.development ? "Development" : "Release"); directory = PathUtility.Combine(directory, UnityPathUtility.GetPlatformName()); // 既存の成果物を破棄. FileUtil.DeleteFileOrDirectory(directory); // 出力先作成. if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } // ファイル名. var fileName = buildParam.ApplicationName + GetBuildTargetExtension(buildTarget); // 出力先. var path = PathUtility.Combine(directory, fileName); // ビルドに含めるシーン. var scenePaths = GetAllScenePaths(); if (scenePaths.Length == 0) { Debug.Log("Nothing to build."); return; } #if UNITY_IOS ProcessForXCode.Prefs.enable = true; #endif // ビルド実行. var option = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None; var error = BuildPipeline.BuildPlayer(scenePaths, path, buildTarget, option); // 後片付け. buildParam.Restore(); Prefs.isBuilding = false; Debug.LogFormat("[Build] : {1}", path); #if UNITY_2018_1_OR_NEWER var success = error == null; #else var success = string.IsNullOrEmpty(error); #endif // 出力先フォルダを開く. if (success) { if (!BatchMode) { if (EditorUtility.DisplayDialog("Notification", "Build Finish!", "Open Folder", "Close")) { System.Diagnostics.Process.Start(directory); } } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId"); _channelId = Body.GetQueryInt("channelId"); if (IsPostBack) { return; } var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var linkType = ELinkTypeUtils.GetEnumType(channelInfo.LinkType); if (channelInfo.ParentId == 0 || linkType == ELinkType.LinkToFirstChannel || linkType == ELinkType.LinkToFirstContent || linkType == ELinkType.LinkToLastAddChannel || linkType == ELinkType.NoLink) { PhFilePath.Visible = false; } var showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, true, TbChannelFilePathRule.ClientID); BtnCreateChannelRule.Attributes.Add("onclick", showPopWinString); showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, false, TbContentFilePathRule.ClientID); BtnCreateContentRule.Attributes.Add("onclick", showPopWinString); TbFilePath.Text = string.IsNullOrEmpty(channelInfo.FilePath) ? PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false) : channelInfo.FilePath; TbChannelFilePathRule.Text = string.IsNullOrEmpty(channelInfo.ChannelFilePathRule) ? PathUtility.GetChannelFilePathRule(SiteInfo, _channelId) : channelInfo.ChannelFilePathRule; TbContentFilePathRule.Text = string.IsNullOrEmpty(channelInfo.ContentFilePathRule) ? PathUtility.GetContentFilePathRule(SiteInfo, _channelId) : channelInfo.ContentFilePathRule; }
public void PostProcess() { PathUtility.DeleteDirectoryIfExists(this.buildSettings.TempGameDefinitionBuildPath); }
public override void Submit_OnClick(object sender, EventArgs e) { var isSuccess = false; try { var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var filePath = channelInfo.FilePath; if (PhFilePath.Visible) { TbFilePath.Text = TbFilePath.Text.Trim(); if (!string.IsNullOrEmpty(TbFilePath.Text) && !StringUtils.EqualsIgnoreCase(filePath, TbFilePath.Text)) { if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(TbFilePath.Text)) { TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html"); } var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); filePathArrayList.AddRange(DataProvider.TemplateMatchDao.GetAllFilePathBySiteId(SiteId)); if (filePathArrayList.IndexOf(TbFilePath.Text) != -1) { FailMessage("栏目修改失败,栏目页面路径已存在!"); return; } } } if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text)) { var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(TbContentFilePathRule.Text)) { var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePathRule)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } if (TbFilePath.Text != PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false)) { channelInfo.FilePath = TbFilePath.Text; } if (TbChannelFilePathRule.Text != PathUtility.GetChannelFilePathRule(SiteInfo, _channelId)) { channelInfo.ChannelFilePathRule = TbChannelFilePathRule.Text; } if (TbContentFilePathRule.Text != PathUtility.GetContentFilePathRule(SiteInfo, _channelId)) { channelInfo.ContentFilePathRule = TbContentFilePathRule.Text; } DataProvider.ChannelDao.Update(channelInfo); CreateManager.CreateChannel(SiteId, _channelId); Body.AddSiteLog(SiteId, _channelId, 0, "设置页面命名规则", $"栏目:{channelInfo.ChannelName}"); isSuccess = true; } catch (Exception ex) { FailMessage(ex, ex.Message); } if (isSuccess) { LayerUtils.CloseAndRedirect(Page, PageConfigurationCreateRule.GetRedirectUrl(SiteId, _channelId)); } }
private static string NormalizeDirectoryPath(string path) { return(PathUtility.EnsureTrailingSlash(Path.GetFullPath(path))); }
private Project Analyze(AnalyzerManager manager, string path, string?tfm, Dictionary <string, Project> built) { if (manager == null) { throw new ArgumentNullException(nameof(manager)); } if (built == null) { throw new ArgumentNullException(nameof(built)); } path = Path.GetFullPath(path); // Already built this project? if (built.TryGetValue(Path.GetFileName(path), out var project)) { return(project); } project = new Project(path); var result = Build(manager, project, tfm); if (result == null) { throw new InvalidOperationException($"Could not build {path}."); } // Get the asset path. var assetPath = result.GetProjectAssetsFilePath(); if (!File.Exists(assetPath)) { // Todo: Make sure this exists in future throw new InvalidOperationException($"{assetPath} not found. Please run 'dotnet restore'."); } // Set project information. project.TargetFramework = result.TargetFramework; project.LockFilePath = result.GetProjectAssetsFilePath(); // Add the project to the built list. built.Add(Path.GetFileName(path), project); // Get the package references. foreach (var packageReference in result.PackageReferences) { if (packageReference.Value.TryGetValue("Version", out var version)) { project.Packages.Add(new Package(packageReference.Key, version)); } } // Analyze all project references. foreach (var projectReference in result.ProjectReferences) { var projectReferencePath = PathUtility.GetPathRelativeToProject(project, projectReference); var analyzedProjectReference = Analyze(manager, projectReferencePath, project.TargetFramework, built); project.ProjectReferences.Add(analyzedProjectReference); } return(project); }
public override FileModel Load(FileAndType file, ImmutableDictionary <string, object> metadata) { switch (file.Type) { case DocumentType.Article: // TODO: Support dynamic in YAML deserializer try { // MUST be a dictionary var obj = YamlUtility.Deserialize <Dictionary <string, object> >(file.File); // load overwrite fragments string markdownFragmentsContent = null; var markdownFragmentsFile = file.File + ".md"; if (_folderRedirectionManager != null) { markdownFragmentsFile = _folderRedirectionManager.GetRedirectedPath((RelativePath)markdownFragmentsFile).ToString(); } if (EnvironmentContext.FileAbstractLayer.Exists(markdownFragmentsFile)) { markdownFragmentsContent = EnvironmentContext.FileAbstractLayer.ReadAllText(markdownFragmentsFile); } else { // Validate against the schema first, only when markdown fragments don't exist SchemaValidator.Validate(obj); } var content = ConvertToObjectHelper.ConvertToDynamic(obj); if (!(_schema.MetadataReference.GetValue(content) is IDictionary <string, object> pageMetadata)) { pageMetadata = new ExpandoObject(); _schema.MetadataReference.SetValue(ref content, pageMetadata); } foreach (var pair in metadata) { if (!pageMetadata.ContainsKey(pair.Key)) { pageMetadata[pair.Key] = pair.Value; } } var localPathFromRoot = PathUtility.MakeRelativePath(EnvironmentContext.BaseDirectory, EnvironmentContext.FileAbstractLayer.GetPhysicalPath(file.File)); var fm = new FileModel( file, content, serializer: new BinaryFormatter()) { LocalPathFromRoot = localPathFromRoot, }; fm.MarkdownFragmentsModel = new FileModel( new FileAndType( file.BaseDir, markdownFragmentsFile, DocumentType.MarkdownFragments, file.SourceDir, file.DestinationDir), markdownFragmentsContent, serializer: new BinaryFormatter()); fm.Properties.Schema = _schema; fm.Properties.Metadata = pageMetadata; fm.MarkdownFragmentsModel.Properties.MarkdigMarkdownService = _markdigMarkdownService; fm.MarkdownFragmentsModel.Properties.Metadata = pageMetadata; if (markdownFragmentsContent != null) { fm.MarkdownFragmentsModel.LocalPathFromRoot = PathUtility.MakeRelativePath( EnvironmentContext.BaseDirectory, EnvironmentContext.FileAbstractLayer.GetPhysicalPath(markdownFragmentsFile)); } return(fm); } catch (YamlDotNet.Core.YamlException e) { var message = $"{file.File} is not in supported format: {e.Message}"; Logger.LogError(message, code: ErrorCodes.Build.InvalidYamlFile); throw new DocumentException(message, e); } case DocumentType.Overwrite: return(OverwriteDocumentReader.Read(file)); default: throw new NotSupportedException(); } }
internal static IEnumerable <PhysicalPackageFile> CollectAdditionalFiles( DirectoryInfoBase rootDirectory, IEnumerable <PackIncludeEntry> projectFileGlobs, string projectFilePath, IList <DiagnosticMessage> diagnostics) { foreach (var entry in projectFileGlobs) { // Evaluate the globs on the right var matcher = new Matcher(); matcher.AddIncludePatterns(entry.SourceGlobs); var results = matcher.Execute(rootDirectory); var files = results.Files.ToList(); // Check for illegal characters if (string.IsNullOrEmpty(entry.Target)) { diagnostics.Add(new DiagnosticMessage( ErrorCodes.NU1003, $"Invalid '{ProjectFilesCollection.PackIncludePropertyName}' section. The target '{entry.Target}' is invalid, " + "targets must either be a file name or a directory suffixed with '/'. " + "The root directory of the package can be specified by using a single '/' character.", projectFilePath, DiagnosticMessageSeverity.Error, entry.Line, entry.Column)); continue; } if (entry.Target.Split('/').Any(s => s.Equals(".") || s.Equals(".."))) { diagnostics.Add(new DiagnosticMessage( ErrorCodes.NU1004, $"Invalid '{ProjectFilesCollection.PackIncludePropertyName}' section. " + $"The target '{entry.Target}' contains path-traversal characters ('.' or '..'). " + "These characters are not permitted in target paths.", projectFilePath, DiagnosticMessageSeverity.Error, entry.Line, entry.Column)); continue; } // Check the arity of the left if (entry.Target.EndsWith("/")) { var dir = entry.Target.Substring(0, entry.Target.Length - 1).Replace('/', Path.DirectorySeparatorChar); foreach (var file in files) { yield return(new PhysicalPackageFile() { SourcePath = Path.Combine(rootDirectory.FullName, PathUtility.GetPathWithDirectorySeparator(file.Path)), TargetPath = Path.Combine(dir, PathUtility.GetPathWithDirectorySeparator(file.Stem)) }); } } else { // It's a file. If the glob matched multiple things, we're sad :( if (files.Count > 1) { // Arity mismatch! string sourceValue = entry.SourceGlobs.Length == 1 ? $"\"{entry.SourceGlobs[0]}\"" : ("[" + string.Join(",", entry.SourceGlobs.Select(v => $"\"{v}\"")) + "]"); diagnostics.Add(new DiagnosticMessage( ErrorCodes.NU1005, $"Invalid '{ProjectFilesCollection.PackIncludePropertyName}' section. " + $"The target '{entry.Target}' refers to a single file, but the pattern {sourceValue} " + "produces multiple files. To mark the target as a directory, suffix it with '/'.", projectFilePath, DiagnosticMessageSeverity.Error, entry.Line, entry.Column)); } else { yield return(new PhysicalPackageFile() { SourcePath = Path.Combine(rootDirectory.FullName, files[0].Path), TargetPath = PathUtility.GetPathWithDirectorySeparator(entry.Target) }); } } } }
// The targetpaths returned from this function contain the directory in the nuget package where the file would go to. The filename is added later on to the target path. // whether or not the filename is added later on is dependent upon the fact that does the targetpath resolved here ends with a directory separator char or not. private IEnumerable <ContentMetadata> GetContentMetadata(IMSBuildItem packageFile, string sourcePath, PackArgs packArgs, string[] contentTargetFolders) { var targetPaths = contentTargetFolders .Select(PathUtility.EnsureTrailingSlash) .ToList(); var isPackagePathSpecified = packageFile.Properties.Contains("PackagePath"); // if user specified a PackagePath, then use that. Look for any ** which are indicated by the RecrusiveDir metadata in msbuild. if (isPackagePathSpecified) { // The rule here is that if the PackagePath is an empty string, then we add the file to the root of the package. // Instead if it is a ';' delimited string, then the user needs to specify a '\' to indicate that the file should go to the root of the package. var packagePathString = packageFile.GetProperty("PackagePath"); targetPaths = packagePathString == null ? new string[] { string.Empty }.ToList() : MSBuildStringUtility.Split(packagePathString) .Distinct() .ToList(); var recursiveDir = packageFile.GetProperty("RecursiveDir"); // The below NuGetRecursiveDir workaround needs to be done due to msbuild bug https://github.com/Microsoft/msbuild/issues/3121 recursiveDir = string.IsNullOrEmpty(recursiveDir) ? packageFile.GetProperty("NuGetRecursiveDir") : recursiveDir; if (!string.IsNullOrEmpty(recursiveDir)) { var newTargetPaths = new List <string>(); var fileName = Path.GetFileName(sourcePath); foreach (var targetPath in targetPaths) { newTargetPaths.Add(PathUtility.GetStringComparerBasedOnOS(). Compare(Path.GetExtension(fileName), Path.GetExtension(targetPath)) == 0 && !string.IsNullOrEmpty(Path.GetExtension(fileName)) ? targetPath : Path.Combine(targetPath, recursiveDir)); } targetPaths = newTargetPaths; } } var buildActionString = packageFile.GetProperty("BuildAction"); var buildAction = BuildAction.Parse(string.IsNullOrEmpty(buildActionString) ? "None" : buildActionString); // TODO: Do the work to get the right language of the project, tracked via https://github.com/NuGet/Home/issues/4100 var language = buildAction.Equals(BuildAction.Compile) ? "cs" : "any"; var setOfTargetPaths = new HashSet <string>(targetPaths, PathUtility.GetStringComparerBasedOnOS()); // If package path wasn't specified, then we expand the "contentFiles" value we // got from ContentTargetFolders and expand it to contentFiles/any/<TFM>/ if (!isPackagePathSpecified) { if (setOfTargetPaths.Remove("contentFiles" + Path.DirectorySeparatorChar) || setOfTargetPaths.Remove("contentFiles")) { foreach (var framework in packArgs.PackTargetArgs.TargetFrameworks) { setOfTargetPaths.Add(PathUtility.EnsureTrailingSlash( Path.Combine("contentFiles", language, framework.GetShortFolderName() ))); } } } // this if condition means there is no package path provided, file is within the project directory // and the target path should preserve this relative directory structure. // This case would be something like : // <Content Include= "folderA\folderB\abc.txt"> // Since the package path wasn't specified, we will add this to the package paths obtained via ContentTargetFolders and preserve // relative directory structure if (!isPackagePathSpecified && sourcePath.StartsWith(packArgs.CurrentDirectory, StringComparison.CurrentCultureIgnoreCase) && !Path.GetFileName(sourcePath) .Equals(packageFile.GetProperty(IdentityProperty), StringComparison.CurrentCultureIgnoreCase)) { var newTargetPaths = new List <string>(); var identity = packageFile.GetProperty(IdentityProperty); // Identity can be a rooted absolute path too, in which case find the path relative to the current directory if (Path.IsPathRooted(identity)) { identity = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(packArgs.CurrentDirectory), identity); identity = Path.GetDirectoryName(identity); } // If identity is not a rooted path, then it is a relative path to the project directory else if (identity.EndsWith(Path.GetFileName(sourcePath), StringComparison.CurrentCultureIgnoreCase)) { identity = Path.GetDirectoryName(identity); } foreach (var targetPath in setOfTargetPaths) { var newTargetPath = Path.Combine(targetPath, identity); // We need to do this because evaluated identity in the above line of code can be an empty string // in the case when the original identity string was the absolute path to a file in project directory, and is in // the same directory as the csproj file. newTargetPath = PathUtility.EnsureTrailingSlash(newTargetPath); newTargetPaths.Add(newTargetPath); } setOfTargetPaths = new HashSet <string>(newTargetPaths, PathUtility.GetStringComparerBasedOnOS()); } // we take the final set of evaluated target paths and append the file name to it if not // already done. we check whether the extension of the target path is the same as the extension // of the source path and add the filename accordingly. var totalSetOfTargetPaths = new List <string>(); foreach (var targetPath in setOfTargetPaths) { var currentPath = targetPath; var fileName = Path.GetFileName(sourcePath); if (string.IsNullOrEmpty(Path.GetExtension(fileName)) || !Path.GetExtension(fileName) .Equals(Path.GetExtension(targetPath), StringComparison.OrdinalIgnoreCase)) { currentPath = Path.Combine(targetPath, fileName); } totalSetOfTargetPaths.Add(currentPath); } return(totalSetOfTargetPaths.Select(target => new ContentMetadata() { BuildAction = buildAction.Value, Source = sourcePath, Target = target, CopyToOutput = packageFile.GetProperty("PackageCopyToOutput"), Flatten = packageFile.GetProperty("PackageFlatten") })); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "RootPath", "CurrentRootPath", "HiddenClientID"); _rootPath = AuthRequest.GetQueryString("RootPath").TrimEnd('/'); _currentRootPath = AuthRequest.GetQueryString("CurrentRootPath"); _hiddenClientId = AuthRequest.GetQueryString("HiddenClientID"); if (string.IsNullOrEmpty(_currentRootPath)) { _currentRootPath = SiteInfo.Additional.ConfigSelectFileCurrentUrl.TrimEnd('/'); } else { SiteInfo.Additional.ConfigSelectFileCurrentUrl = _currentRootPath; DataProvider.SiteDao.Update(SiteInfo); } _currentRootPath = _currentRootPath.TrimEnd('/'); _directoryPath = PathUtility.MapPath(SiteInfo, _currentRootPath); DirectoryUtils.CreateDirectoryIfNotExists(_directoryPath); if (!DirectoryUtils.IsDirectoryExists(_directoryPath)) { PageUtils.RedirectToErrorPage("文件夹不存在!"); return; } if (Page.IsPostBack) { return; } BtnUpload.Attributes.Add("onclick", ModalUploadFile.GetOpenWindowStringToList(SiteId, EUploadType.File, _currentRootPath)); DdlListType.Items.Add(new ListItem("显示缩略图", "Image")); DdlListType.Items.Add(new ListItem("显示详细信息", "List")); if (AuthRequest.IsQueryExists("ListType")) { ControlUtils.SelectSingleItem(DdlListType, AuthRequest.GetQueryString("ListType")); } var previousUrls = Session["PreviousUrls"] as ArrayList ?? new ArrayList(); var currentUrl = GetRedirectUrl(_currentRootPath); if (previousUrls.Count > 0) { var url = previousUrls[previousUrls.Count - 1] as string; if (!string.Equals(url, currentUrl)) { previousUrls.Add(currentUrl); Session["PreviousUrls"] = previousUrls; } } else { previousUrls.Add(currentUrl); Session["PreviousUrls"] = previousUrls; } var navigationBuilder = new StringBuilder(); var directoryNames = _currentRootPath.Split('/'); var linkCurrentRootPath = _rootPath; foreach (var directoryName in directoryNames) { if (!string.IsNullOrEmpty(directoryName)) { if (directoryName.Equals("~")) { navigationBuilder.Append($"<a href='{GetRedirectUrl(_rootPath)}'>根目录</a>"); } else if (directoryName.Equals("@")) { navigationBuilder.Append( $"<a href='{GetRedirectUrl(_rootPath)}'>{SiteManager.GetSiteInfo(SiteId).SiteDir}</a>"); } else { linkCurrentRootPath += "/" + directoryName; navigationBuilder.Append($"<a href='{GetRedirectUrl(linkCurrentRootPath)}'>{directoryName}</a>"); } navigationBuilder.Append("\\"); } } LtlCurrentDirectory.Text = navigationBuilder.ToString(); FillFileSystems(false); }
public PackageBuilder GetPackageBuilder(IPackTaskRequest <IMSBuildItem> request) { // Load the assets JSON file produced by restore. var assetsFilePath = Path.Combine(request.RestoreOutputPath, LockFileFormat.AssetsFileName); if (!File.Exists(assetsFilePath)) { throw new PackagingException(NuGetLogCode.NU5023, string.Format( CultureInfo.CurrentCulture, Strings.AssetsFileNotFound, assetsFilePath)); } var builder = new PackageBuilder(request.Deterministic) { Id = request.PackageId, Description = request.Description, Title = request.Title, Copyright = request.Copyright, ReleaseNotes = request.ReleaseNotes, RequireLicenseAcceptance = request.RequireLicenseAcceptance, PackageTypes = ParsePackageTypes(request) }; if (request.DevelopmentDependency) { builder.DevelopmentDependency = true; } if (request.PackageVersion != null) { NuGetVersion version; if (!NuGetVersion.TryParse(request.PackageVersion, out version)) { throw new PackagingException(NuGetLogCode.NU5024, string.Format( CultureInfo.CurrentCulture, Strings.InvalidPackageVersion, request.PackageVersion)); } builder.Version = version; } else { builder.Version = new NuGetVersion("1.0.0"); } if (request.Authors != null) { builder.Authors.AddRange(request.Authors); } if (request.Tags != null) { builder.Tags.AddRange(request.Tags); } Uri tempUri; if (Uri.TryCreate(request.LicenseUrl, UriKind.Absolute, out tempUri)) { builder.LicenseUrl = tempUri; } if (Uri.TryCreate(request.ProjectUrl, UriKind.Absolute, out tempUri)) { builder.ProjectUrl = tempUri; } if (Uri.TryCreate(request.IconUrl, UriKind.Absolute, out tempUri)) { builder.IconUrl = tempUri; } if (!string.IsNullOrEmpty(request.RepositoryUrl) || !string.IsNullOrEmpty(request.RepositoryType)) { builder.Repository = new RepositoryMetadata( request.RepositoryType, request.RepositoryUrl, request.RepositoryBranch, request.RepositoryCommit); } builder.LicenseMetadata = BuildLicenseMetadata(request); builder.Icon = request.PackageIcon; if (request.MinClientVersion != null) { Version version; if (!Version.TryParse(request.MinClientVersion, out version)) { throw new PackagingException(NuGetLogCode.NU5022, string.Format( CultureInfo.CurrentCulture, Strings.InvalidMinClientVersion, request.MinClientVersion)); } builder.MinClientVersion = version; } // The assets file is necessary for project and package references. Pack should not do any traversal, // so we leave that work up to restore (which produces the assets file). var lockFileFormat = new LockFileFormat(); var assetsFile = lockFileFormat.Read(assetsFilePath); if (assetsFile.PackageSpec == null) { throw new PackagingException(NuGetLogCode.NU5025, string.Format( CultureInfo.CurrentCulture, Strings.AssetsFileDoesNotHaveValidPackageSpec, assetsFilePath)); } var projectRefToVersionMap = new Dictionary <string, string>(PathUtility.GetStringComparerBasedOnOS()); if (request.ProjectReferencesWithVersions != null && request.ProjectReferencesWithVersions.Any()) { projectRefToVersionMap = request .ProjectReferencesWithVersions .ToDictionary(msbuildItem => msbuildItem.Identity, msbuildItem => msbuildItem.GetProperty("ProjectVersion"), PathUtility.GetStringComparerBasedOnOS()); } var nuGetFrameworkComparer = new NuGetFrameworkFullComparer(); var frameworksWithSuppressedDependencies = new HashSet <NuGetFramework>(nuGetFrameworkComparer); if (request.FrameworksWithSuppressedDependencies != null && request.FrameworksWithSuppressedDependencies.Any()) { frameworksWithSuppressedDependencies = new HashSet <NuGetFramework>(request.FrameworksWithSuppressedDependencies .Select(t => NuGetFramework.Parse(t.Identity)).ToList(), nuGetFrameworkComparer); } PopulateProjectAndPackageReferences(builder, assetsFile, projectRefToVersionMap, frameworksWithSuppressedDependencies); PopulateFrameworkAssemblyReferences(builder, request); PopulateFrameworkReferences(builder, assetsFile); return(builder); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } if (AuthRequest.IsQueryExists("DeleteDirectory")) { var siteTemplateDir = AuthRequest.GetQueryString("SiteTemplateDir"); try { SiteTemplateManager.Instance.DeleteSiteTemplate(siteTemplateDir); AuthRequest.AddAdminLog("删除站点模板", $"站点模板:{siteTemplateDir}"); SuccessDeleteMessage(); } catch (Exception ex) { FailDeleteMessage(ex); } } else if (AuthRequest.IsQueryExists("DeleteZipFile")) { var fileName = AuthRequest.GetQueryString("FileName"); try { SiteTemplateManager.Instance.DeleteZipSiteTemplate(fileName); AuthRequest.AddAdminLog("删除未解压站点模板", $"站点模板:{fileName}"); SuccessDeleteMessage(); } catch (Exception ex) { FailDeleteMessage(ex); } } if (Page.IsPostBack) { return; } VerifySystemPermissions(ConfigManager.SettingsPermissions.Site); _sortedlist = SiteTemplateManager.Instance.GetSiteTemplateSortedList(); var directoryList = new List <DirectoryInfo>(); foreach (string directoryName in _sortedlist.Keys) { var directoryPath = PathUtility.GetSiteTemplatesPath(directoryName); var dirInfo = new DirectoryInfo(directoryPath); directoryList.Add(dirInfo); } RptDirectories.DataSource = directoryList; RptDirectories.ItemDataBound += RptDirectories_ItemDataBound; RptDirectories.DataBind(); var fileNames = SiteTemplateManager.Instance.GetZipSiteTemplateList(); var fileList = new List <FileInfo>(); foreach (var fileName in fileNames) { if (!DirectoryUtils.IsDirectoryExists(PathUtility.GetSiteTemplatesPath(PathUtils.GetFileNameWithoutExtension(fileName)))) { var filePath = PathUtility.GetSiteTemplatesPath(fileName); var fileInfo = new FileInfo(filePath); fileList.Add(fileInfo); } } if (fileList.Count > 0) { RptZipFiles.Visible = true; RptZipFiles.DataSource = fileList; RptZipFiles.ItemDataBound += RptZipFiles_ItemDataBound; RptZipFiles.DataBind(); } else { RptZipFiles.Visible = false; } BtnImport.Attributes.Add("onclick", ModalImportZip.GetOpenWindowString(ModalImportZip.TypeSiteTemplate)); }