/// <inheritdoc/> public BuildScriptSnippet GenerateBashBuildScriptSnippet( BuildScriptGeneratorContext context, PlatformDetectorResult detectorResult) { var dotNetCorePlatformDetectorResult = detectorResult as DotNetCorePlatformDetectorResult; if (dotNetCorePlatformDetectorResult == null) { throw new ArgumentException( $"Expected '{nameof(detectorResult)}' argument to be of type " + $"'{typeof(DotNetCorePlatformDetectorResult)}' but got '{detectorResult.GetType()}'."); } var manifestFileProperties = new Dictionary <string, string>(); manifestFileProperties[ManifestFilePropertyKeys.OperationId] = context.OperationId; manifestFileProperties[ManifestFilePropertyKeys.DotNetCoreRuntimeVersion] = dotNetCorePlatformDetectorResult.PlatformVersion; manifestFileProperties[ManifestFilePropertyKeys.DotNetCoreSdkVersion] = dotNetCorePlatformDetectorResult.SdkVersion; // optional field string outputType = dotNetCorePlatformDetectorResult.OutputType; if (!string.IsNullOrEmpty(outputType)) { manifestFileProperties[ManifestFilePropertyKeys.OutputType] = outputType; } var projectFile = dotNetCorePlatformDetectorResult.ProjectFile; if (string.IsNullOrEmpty(projectFile)) { return(null); } var templateProperties = new DotNetCoreBashBuildSnippetProperties { ProjectFile = projectFile, Configuration = GetBuildConfiguration(), }; var script = TemplateHelper.Render( TemplateHelper.TemplateResource.DotNetCoreSnippet, templateProperties, _logger); SetStartupFileNameInfoInManifestFile(context, projectFile, manifestFileProperties); return(new BuildScriptSnippet { BashBuildScriptSnippet = script, BuildProperties = manifestFileProperties, // Setting this to false to avoid copying files like '.cs' to the destination CopySourceDirectoryContentToDestinationDirectory = false, }); }
public BuildScriptSnippet GenerateBashBuildScriptSnippet(BuildScriptGeneratorContext context) { var buildProperties = new Dictionary <string, string>(); buildProperties[ManifestFilePropertyKeys.OperationId] = context.OperationId; (string projectFile, string publishDir) = GetProjectFileAndPublishDir(context); if (string.IsNullOrEmpty(projectFile) || string.IsNullOrEmpty(publishDir)) { return(null); } SetStartupFileNameInfoInManifestFile(context, projectFile, buildProperties); bool zipAllOutput = ShouldZipAllOutput(context); buildProperties[ManifestFilePropertyKeys.ZipAllOutput] = zipAllOutput.ToString().ToLowerInvariant(); _environmentSettingsProvider.TryGetAndLoadSettings(out var environmentSettings); (var preBuildCommand, var postBuildCommand) = PreAndPostBuildCommandHelper.GetPreAndPostBuildCommands( context.SourceRepo, environmentSettings); var templateProperties = new DotNetCoreBashBuildSnippetProperties { ProjectFile = projectFile, PublishDirectory = publishDir, BuildProperties = buildProperties, BenvArgs = $"dotnet={context.DotNetCoreVersion}", DirectoriesToExcludeFromCopyToIntermediateDir = GetDirectoriesToExcludeFromCopyToIntermediateDir( context), PreBuildCommand = preBuildCommand, PostBuildCommand = postBuildCommand, ManifestFileName = FilePaths.BuildManifestFileName, ManifestDir = context.ManifestDir, ZipAllOutput = zipAllOutput, Configuration = GetBuildConfiguration(), }; var script = TemplateHelper.Render( TemplateHelper.TemplateResource.DotNetCoreSnippet, templateProperties, _logger); return(new BuildScriptSnippet { BashBuildScriptSnippet = script, IsFullScript = true }); }
public BuildScriptSnippet GenerateBashBuildScriptSnippet(BuildScriptGeneratorContext scriptGeneratorContext) { (string projectFile, string publishDir) = GetProjectFileAndPublishDir(scriptGeneratorContext.SourceRepo); if (string.IsNullOrEmpty(projectFile) || string.IsNullOrEmpty(publishDir)) { return(null); } var props = new DotNetCoreBashBuildSnippetProperties { ProjectFile = projectFile, PublishDirectory = publishDir }; string script = TemplateHelpers.Render(TemplateHelpers.TemplateResource.DotNetCoreSnippet, props, _logger); return(new BuildScriptSnippet { BashBuildScriptSnippet = script }); }
/// <inheritdoc/> public BuildScriptSnippet GenerateBashBuildScriptSnippet( BuildScriptGeneratorContext context, PlatformDetectorResult detectorResult) { var dotNetCorePlatformDetectorResult = detectorResult as DotNetCorePlatformDetectorResult; if (dotNetCorePlatformDetectorResult == null) { throw new ArgumentException( $"Expected '{nameof(detectorResult)}' argument to be of type " + $"'{typeof(DotNetCorePlatformDetectorResult)}' but got '{detectorResult.GetType()}'."); } var versionMap = _versionProvider.GetSupportedVersions(); string globalJsonSdkVersion = null; if (_commonOptions.EnableDynamicInstall) { var availableSdks = versionMap.Values; globalJsonSdkVersion = _globalJsonSdkResolver.GetSatisfyingSdkVersion( context.SourceRepo, detectorResult.PlatformVersion, availableSdks); } var manifestFileProperties = new Dictionary <string, string>(); manifestFileProperties[ManifestFilePropertyKeys.OperationId] = context.OperationId; manifestFileProperties[ManifestFilePropertyKeys.DotNetCoreRuntimeVersion] = detectorResult.PlatformVersion; if (string.IsNullOrEmpty(globalJsonSdkVersion)) { manifestFileProperties[ManifestFilePropertyKeys.DotNetCoreSdkVersion] = versionMap[detectorResult.PlatformVersion]; } else { manifestFileProperties[ManifestFilePropertyKeys.DotNetCoreSdkVersion] = globalJsonSdkVersion; } var projectFile = dotNetCorePlatformDetectorResult.ProjectFile; if (string.IsNullOrEmpty(projectFile)) { return(null); } var templateProperties = new DotNetCoreBashBuildSnippetProperties { ProjectFile = projectFile, Configuration = GetBuildConfiguration(), }; var script = TemplateHelper.Render( TemplateHelper.TemplateResource.DotNetCoreSnippet, templateProperties, _logger); SetStartupFileNameInfoInManifestFile(context, projectFile, manifestFileProperties); return(new BuildScriptSnippet { BashBuildScriptSnippet = script, BuildProperties = manifestFileProperties, // Setting this to false to avoid copying files like '.cs' to the destination CopySourceDirectoryContentToDestinationDirectory = false, }); }
/// <inheritdoc/> public BuildScriptSnippet GenerateBashBuildScriptSnippet(BuildScriptGeneratorContext context) { var versionMap = _versionProvider.GetSupportedVersions(); string installationScriptSnippet = null; string globalJsonSdkVersion = null; if (_cliOptions.EnableDynamicInstall) { _logger.LogDebug("Dynamic install is enabled."); var availableSdks = versionMap.Values; globalJsonSdkVersion = _globalJsonSdkResolver.GetSatisfyingSdkVersion( context.SourceRepo, context.ResolvedDotNetCoreRuntimeVersion, availableSdks); if (_platformInstaller.IsVersionAlreadyInstalled( context.ResolvedDotNetCoreRuntimeVersion, globalJsonSdkVersion)) { _logger.LogDebug( "DotNetCore runtime version {runtimeVersion} is already installed. " + "So skipping installing it again.", context.ResolvedDotNetCoreRuntimeVersion); } else { _logger.LogDebug( "DotNetCore runtime version {runtimeVersion} is not installed. " + "So generating an installation script snippet for it.", context.ResolvedDotNetCoreRuntimeVersion); installationScriptSnippet = _platformInstaller.GetInstallerScriptSnippet( context.ResolvedDotNetCoreRuntimeVersion, globalJsonSdkVersion); } } else { _logger.LogDebug("Dynamic install is not enabled."); } var manifestFileProperties = new Dictionary <string, string>(); manifestFileProperties[ManifestFilePropertyKeys.OperationId] = context.OperationId; manifestFileProperties[ManifestFilePropertyKeys.DotNetCoreRuntimeVersion] = context.ResolvedDotNetCoreRuntimeVersion; if (string.IsNullOrEmpty(globalJsonSdkVersion)) { manifestFileProperties[ManifestFilePropertyKeys.DotNetCoreSdkVersion] = versionMap[context.ResolvedDotNetCoreRuntimeVersion]; } else { manifestFileProperties[ManifestFilePropertyKeys.DotNetCoreSdkVersion] = globalJsonSdkVersion; } var projectFile = _projectFileProvider.GetRelativePathToProjectFile(context); if (string.IsNullOrEmpty(projectFile)) { return(null); } var templateProperties = new DotNetCoreBashBuildSnippetProperties { ProjectFile = projectFile, Configuration = GetBuildConfiguration(), }; var script = TemplateHelper.Render( TemplateHelper.TemplateResource.DotNetCoreSnippet, templateProperties, _logger); SetStartupFileNameInfoInManifestFile(context, projectFile, manifestFileProperties); return(new BuildScriptSnippet { BashBuildScriptSnippet = script, BuildProperties = manifestFileProperties, PlatformInstallationScriptSnippet = installationScriptSnippet, // Setting this to false to avoid copying files like '.cs' to the destination CopySourceDirectoryContentToDestinationDirectory = false, }); }