Skip to content

Commit 1aa778e

Browse files
authored
Merge pull request #33 from CZEMacLeod/fix-solutionname-32
Handle case where SolutionName is not set (or set to *Undefined*) Set-WebApplicationTargetsPath.ps1: Logic to retrieve Visual Studio installation path and set the WebApplicationsTargetPath environment variable to make it easy to run from the command line.
2 parents 71717d4 + 9076f75 commit 1aa778e

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

C3D.Extensions.Aspire.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{E1FFCD98
2020
build\nuget.publish.config = build\nuget.publish.config
2121
README.md = README.md
2222
build\RemoveCert.ps1 = build\RemoveCert.ps1
23+
Set-WebApplicationTargetsPath.ps1 = Set-WebApplicationTargetsPath.ps1
2324
build\Test.snk = build\Test.snk
2425
EndProjectSection
2526
EndProject

Set-WebApplicationTargetsPath.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$vs_path = vswhere -latest -property installationPath
2+
$vs_version = [System.Version]::Parse($(vswhere -latest -property installationVersion))
3+
$vs_tools_path = "$vs_path\MSBuild\Microsoft\VisualStudio\v$($vs_version.Major).0"
4+
$web_applications_target_path = "$vs_tools_path\WebApplications\Microsoft.WebApplication.targets"
5+
$env:WebApplicationsTargetPath=$web_applications_target_path

src/C3D/Extensions/Aspire/IISExpress/IISEndPointConfigurator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public IISEndPointConfigurator(DistributedApplicationModel appModel,
2828

2929
public void Configure()
3030
{
31-
var appHostConfig = options.Value.ApplicationHostConfig!;
31+
var appHostConfig = options.Value.ApplicationHostConfig ?? ApplicationHostConfigurationExtensions.GetTempConfigFile();
3232
foreach (var project in appModel.Resources.OfType<IISExpressProjectResource>())
3333
{
3434
try

src/C3D/Extensions/Aspire/IISExpress/IISExpressOptions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
8989
return results;
9090
}
9191

92-
public string? ApplicationHostConfig => SolutionDir is null || SolutionName is null ? null :
92+
public string? ApplicationHostConfig =>
93+
(string.IsNullOrEmpty(SolutionDir) ||
94+
(string.IsNullOrEmpty(SolutionName) ||
95+
SolutionName.IndexOfAny(Path.GetInvalidFileNameChars())!=-1
96+
)
97+
) ? null :
9398
System.IO.Path.Combine(
9499
SolutionDir,
95100
".vs",

0 commit comments

Comments
 (0)