public ManagerTemplate() { PackageDirectoryTemplate crRoot = Package.AddDirectory(Manager.PCRDir).WithAttributes(FileAttributes.Hidden); _ = crRoot.AddDirectory(Manager.PExtensionDir); _ = crRoot.AddFile(Manager.PSettings).UseTemplate(new TextFileTemplate(new StringTemplate(JsonFormatter.Serialize(new CRSettings())))); }
public WorkspaceTemplate() { PackageDirectoryTemplate crRoot = Package.AddDirectory(Workspace.PCRRoot).WithAttributes(FileAttributes.Hidden); _ = crRoot.AddDirectory(Workspace.PTemplatesRoot); _ = crRoot.AddFile(Workspace.PSettings).UseTemplate(new TextFileTemplate(new StringTemplate(JsonFormatter.Serialize(new WorkspaceSettings { Version = new Version(0, 0, 1, 0) })))); }
public async Task Directories() { using TempDirectory d = new TempDirectory(); { PackageDirectoryTemplate pf = new PackageDirectoryTemplate() .UseName("") .UseAttributes(FileAttributes.Directory) .WithAttributes(FileAttributes.Archive) .WithoutAttributes(FileAttributes.System); _ = pf.AddFile("a.txt").UseTemplate(new TextFileTemplate("hello")); _ = pf.AddDirectory("subdir"); _ = await pf.Resolve(new ResolveContext().WithVariable(DirectoryTemplate.Var, d.Directory.FullName)); d.Directory.Refresh(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Assert.AreEqual(FileAttributes.Archive, d.Directory.Attributes & FileAttributes.Archive); } } { PackageDirectoryTemplate pf = new PackageDirectoryTemplate(); await pf.From(d.Directory, true); _ = pf.UseName().WithoutAttributes(FileAttributes.Archive); _ = await pf.Resolve(new ResolveContext().WithVariable(DirectoryTemplate.Var, d.Directory.FullName)); d.Directory.Refresh(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Assert.AreNotEqual(FileAttributes.Archive, d.Directory.Attributes & FileAttributes.Archive); } Assert.AreEqual("hello", File.ReadAllText(Path.Join(d.Directory.FullName, "a.txt"))); Assert.IsTrue(Directory.Exists(Path.Join(d.Directory.FullName, "subdir"))); } { PackageDirectoryTemplate pf = new PackageDirectoryTemplate(); await pf.From(d.Directory, false); _ = pf.UseName() .WithoutAttributes(FileAttributes.Archive); _ = await pf.Resolve(new ResolveContext().WithVariable(DirectoryTemplate.Var, d.Directory.FullName)); d.Directory.Refresh(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Assert.AreNotEqual(FileAttributes.Archive, d.Directory.Attributes & FileAttributes.Archive); } Assert.AreEqual("hello", File.ReadAllText(Path.Join(d.Directory.FullName, "a.txt"))); Assert.IsTrue(Directory.Exists(Path.Join(d.Directory.FullName, "subdir"))); } }