示例#1
0
        private void WriteApplicationProjectJsonFile(string applicationFolder)
        {
            var projectFileName      = Path.GetFileName(_project.ProjectFilePath);
            var appScriptProjectFile = Path.Combine(
                applicationFolder,
                projectFileName);

            File.Copy(
                _project.ProjectFilePath,
                appScriptProjectFile,
                overwrite: true);

            // If the source file is readonly, the destination will be readonly too
            // so remove the readonly attribute
            FileOperationUtils.MakeWritable(appScriptProjectFile);

            Runtime.Project appProject;
            Runtime.Project.TryGetProject(appScriptProjectFile, out appProject);

            ModifyJson(appScriptProjectFile, projectFile =>
            {
                projectFile["entryPoint"] = _project.Name;
                projectFile["loadable"]   = false;

                var dependencies = new JObject();
                projectFile[nameof(dependencies)] = dependencies;
                dependencies[_project.Name]       = _project.Version.ToString();
            });

            _packageBuilder.Files.Add(new PhysicalPackageFile()
            {
                SourcePath = appScriptProjectFile,
                TargetPath = Path.Combine(CommandsFolderName, projectFileName)
            });
        }
示例#2
0
        public void Write(string filePath, LockFile lockFile)
        {
            // Make sure that if the lock file exists, it is not readonly
            if (File.Exists(filePath))
            {
                FileOperationUtils.MakeWritable(filePath);
            }

            using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                Write(stream, lockFile);
            }
        }