Example #1
0
        /// <param name="publishDirName">
        /// The directory inside of <see cref="MeditationLogContext.DevopsDistributionPath"/>
        /// to place the published project.
        /// Set to null to have it be <paramref name="rid"/>.
        /// </param>
        public void DevopsPublish(string rid, string?publishDirName = null)
        {
            const string configuration = "Release";

            var publishDir = context.DevopsDistributionPath.Combine(publishDirName ?? rid);

            context.EnsureDirectoryExists(publishDir);
            context.CleanDirectory(publishDir);

            var publishSettings = new DotNetCorePublishSettings
            {
                Configuration   = configuration,
                OutputDirectory = publishDir,
                MSBuildSettings = MsBuildHelpers.GetMsBuildSettings(configuration),

                // We'll be running in a docker image with the runtime, no need
                // to include the entire runtime.
                SelfContained = false,
                Runtime       = rid
            };

            context.DotNetCorePublish(
                context.DevopsCsProj.ToString(),
                publishSettings
                );
        }
        // ----------------- Functions -----------------

        public override void Run(MeditationLogContext context)
        {
            const string configuration = "Release";

            var publishDir = context.DockerPath.Combine("bin");

            context.EnsureDirectoryExists(publishDir);
            context.CleanDirectory(publishDir);

            var publishSettings = new DotNetCorePublishSettings
            {
                Configuration   = configuration,
                OutputDirectory = publishDir,
                MSBuildSettings = MsBuildHelpers.GetMsBuildSettings(configuration),
            };

            context.DotNetCorePublish(
                context.GuiCsProject.ToString(),
                publishSettings
                );

            // No need to inclue these files in the docker image,
            // may as well decrease the file size a bit.
            var filesToDelete = new FilePath[]
            {
                publishDir.CombineWithFilePath("Meditu.Gui.exe"),
                publishDir.CombineWithFilePath("Meditu.Gui")
            };

            foreach (FilePath path in filesToDelete)
            {
                if (context.FileExists(path))
                {
                    context.DeleteFile(path);
                }
            }
        }