Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
182 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace DotNetReleaser.Configuration; | ||
|
||
public class WebAppConfiguration : ConfigurationBase | ||
{ | ||
public WebAppConfiguration() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace DotNetReleaser; | ||
|
||
public record ProjectPackageInfo(string ProjectFullPath, string Name, string AssemblyName, PackageOutputType OutputType, string Version, string Description, string License, string ProjectUrl, bool IsPackable, bool IsTestProject, string[] ProjectReferences, TargetFrameworkInfo TargetFrameworkInfo); | ||
public record ProjectPackageInfo(string ProjectFullPath, string PackageId, string AssemblyName, PackageOutputType OutputType, string Version, string Description, string License, string ProjectUrl, bool IsPackable, bool IsTestProject, | ||
string[] ProjectReferences, TargetFrameworkInfo TargetFrameworkInfo, bool IsWebApp) | ||
{ | ||
public string ProjectName => Path.GetFileNameWithoutExtension(ProjectFullPath); | ||
|
||
public string? WebAppPublishProfile { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace DotNetReleaser; | ||
|
||
public partial class ReleaserApp | ||
{ | ||
private async Task<bool> BuildAndPublishWebApp(BuildInformation buildInformation) | ||
{ | ||
if (!_config.WebApp.Publish || buildInformation.BuildKind != BuildKind.Publish) return true; | ||
|
||
var webApps = buildInformation.GetAllWebAppProjects(); | ||
if (webApps.Count == 0) return true; | ||
|
||
try | ||
{ | ||
_logger.LogStartGroup("WebApp Publishing"); | ||
|
||
foreach (var webAppProject in buildInformation.GetAllWebAppProjects()) | ||
{ | ||
if (!await BuildAndPublishWebApp(webAppProject)) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
finally | ||
{ | ||
_logger.LogEndGroup(); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private async Task<bool> BuildAndPublishWebApp(ProjectPackageInfo buildPackageInfo) | ||
{ | ||
if (buildPackageInfo.WebAppPublishProfile is null) | ||
{ | ||
Warn($"No PublishProfile for {buildPackageInfo.ProjectName}. Skipping."); | ||
return true; | ||
} | ||
|
||
Info($"Publishing {buildPackageInfo.ProjectName}"); | ||
|
||
//buildPackageInfo | ||
var properties = new Dictionary<string, object>(_config.MSBuild.Properties); | ||
|
||
// We need to explicitly restore the platform RID before trying to build it | ||
var restoreResult = await RunMSBuild(buildPackageInfo.ProjectFullPath, "Restore", properties); | ||
if (restoreResult is null) | ||
{ | ||
// Stop on first error | ||
return false; | ||
} | ||
|
||
properties["PublishProfile"] = buildPackageInfo.WebAppPublishProfile; | ||
|
||
// Publish | ||
var result = await RunMSBuild(buildPackageInfo.ProjectFullPath, "Publish", properties); | ||
|
||
if (result is null) | ||
{ | ||
// Stop on first error | ||
return false; | ||
} | ||
|
||
return true; | ||
|
||
} | ||
} |
Oops, something went wrong.