Beispiel #1
0
        /// <summary>
        /// Creates an app bundle by publishing it to the given directory. It only publishes the release configuration.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="stageDirectory">The directory to which to publish.</param>
        /// <param name="pathsProvider">The provider for paths.</param>
        /// <param name="outputAction">The callback to call with output from the command.</param>
        internal static async Task <bool> CreateAppBundleAsync(
            IParsedProject project,
            string stageDirectory,
            IToolsPathProvider pathsProvider,
            Action <string> outputAction)
        {
            var arguments     = $"publish -o \"{stageDirectory}\" -c Release";
            var externalTools = pathsProvider.GetExternalToolsPath();
            var workingDir    = project.DirectoryPath;
            var env           = new Dictionary <string, string>
            {
                { "PATH", $"{Environment.GetEnvironmentVariable("PATH")};{externalTools}" },
            };

            Debug.WriteLine($"Using tools from {externalTools}");
            Debug.WriteLine($"Setting working directory to {workingDir}");
            Directory.CreateDirectory(stageDirectory);
            outputAction($"dotnet {arguments}");
            bool result = await ProcessUtils.RunCommandAsync(
                file : pathsProvider.GetDotnetPath(),
                args : arguments,
                workingDir : workingDir,
                handler : (o, e) => outputAction(e.Line),
                environment : env);

            await GCloudWrapper.GenerateSourceContext(project.DirectoryPath, stageDirectory);

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// This method stages the application into the <paramref name="stageDirectory"/> by invoking the WebPublish target
        /// present in all Web projects. It publishes to the staging directory by using the FileSystem method.
        /// </summary>
        private static async Task <bool> CreateAppBundleAsync(
            IParsedProject project,
            string stageDirectory,
            IToolsPathProvider toolsPathProvider,
            Action <string> outputAction)
        {
            var arguments = $@"""{project.FullPath}""" + " " +
                            "/p:Configuration=Release " +
                            "/p:Platform=AnyCPU " +
                            "/t:WebPublish " +
                            "/p:WebPublishMethod=FileSystem " +
                            "/p:DeleteExistingFiles=True " +
                            $@"/p:publishUrl=""{stageDirectory}""";

            outputAction($"msbuild.exe {arguments}");
            bool result = await ProcessUtils.RunCommandAsync(toolsPathProvider.GetMsbuildPath(), arguments, (o, e) => outputAction(e.Line));

            // We perform this check here because it is not required to have gcloud installed in order to deploy
            // ASP.NET 4.x apps to GCE VMs. Therefore nothing would have checked for the presence of gcloud before
            // getting here.
            var gcloudValidation = await GCloudWrapper.ValidateGCloudAsync();

            Debug.WriteLineIf(!gcloudValidation.IsValid, "Skipping creating context, gcloud is not installed.");
            if (gcloudValidation.IsValid)
            {
                await GCloudWrapper.GenerateSourceContext(project.DirectoryPath, stageDirectory);
            }

            return(result);
        }
        /// <summary>
        /// This method stages the application into the <paramref name="stageDirectory"/> by invoking the WebPublish target
        /// present in all Web projects. It publishes to the staging directory by using the FileSystem method.
        /// </summary>
        private static async Task <bool> CreateAppBundleAsync(
            IParsedProject project,
            string stageDirectory,
            IToolsPathProvider toolsPathProvider,
            Action <string> outputAction)
        {
            var arguments = $@"""{project.FullPath}""" + " " +
                            "/p:Configuration=Release " +
                            "/p:Platform=AnyCPU " +
                            "/t:WebPublish " +
                            "/p:WebPublishMethod=FileSystem " +
                            "/p:DeleteExistingFiles=True " +
                            $@"/p:publishUrl=""{stageDirectory}""";

            outputAction($"msbuild.exe {arguments}");
            bool result = await ProcessUtils.RunCommandAsync(toolsPathProvider.GetMsbuildPath(), arguments, (o, e) => outputAction(e.Line));

            await GCloudWrapper.GenerateSourceContext(project.DirectoryPath, stageDirectory);

            return(result);
        }