diff --git a/C3D.Extensions.Aspire.sln b/C3D.Extensions.Aspire.sln index 6d4412c..93fe96c 100644 --- a/C3D.Extensions.Aspire.sln +++ b/C3D.Extensions.Aspire.sln @@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{E1FFCD98 build\nuget.publish.config = build\nuget.publish.config README.md = README.md build\RemoveCert.ps1 = build\RemoveCert.ps1 + Set-WebApplicationTargetsPath.ps1 = Set-WebApplicationTargetsPath.ps1 build\Test.snk = build\Test.snk EndProjectSection EndProject diff --git a/Set-WebApplicationTargetsPath.ps1 b/Set-WebApplicationTargetsPath.ps1 new file mode 100644 index 0000000..39836b8 --- /dev/null +++ b/Set-WebApplicationTargetsPath.ps1 @@ -0,0 +1,5 @@ +$vs_path = vswhere -latest -property installationPath +$vs_version = [System.Version]::Parse($(vswhere -latest -property installationVersion)) +$vs_tools_path = "$vs_path\MSBuild\Microsoft\VisualStudio\v$($vs_version.Major).0" +$web_applications_target_path = "$vs_tools_path\WebApplications\Microsoft.WebApplication.targets" +$env:WebApplicationsTargetPath=$web_applications_target_path diff --git a/src/C3D/Extensions/Aspire/IISExpress/IISEndPointConfigurator.cs b/src/C3D/Extensions/Aspire/IISExpress/IISEndPointConfigurator.cs index 2177fb3..4c9e5f8 100644 --- a/src/C3D/Extensions/Aspire/IISExpress/IISEndPointConfigurator.cs +++ b/src/C3D/Extensions/Aspire/IISExpress/IISEndPointConfigurator.cs @@ -28,7 +28,7 @@ public IISEndPointConfigurator(DistributedApplicationModel appModel, public void Configure() { - var appHostConfig = options.Value.ApplicationHostConfig!; + var appHostConfig = options.Value.ApplicationHostConfig ?? ApplicationHostConfigurationExtensions.GetTempConfigFile(); foreach (var project in appModel.Resources.OfType()) { try diff --git a/src/C3D/Extensions/Aspire/IISExpress/IISExpressOptions.cs b/src/C3D/Extensions/Aspire/IISExpress/IISExpressOptions.cs index 6a6872f..d315c02 100644 --- a/src/C3D/Extensions/Aspire/IISExpress/IISExpressOptions.cs +++ b/src/C3D/Extensions/Aspire/IISExpress/IISExpressOptions.cs @@ -89,7 +89,12 @@ public IEnumerable Validate(ValidationContext validationContex return results; } - public string? ApplicationHostConfig => SolutionDir is null || SolutionName is null ? null : + public string? ApplicationHostConfig => + (string.IsNullOrEmpty(SolutionDir) || + (string.IsNullOrEmpty(SolutionName) || + SolutionName.IndexOfAny(Path.GetInvalidFileNameChars())!=-1 + ) + ) ? null : System.IO.Path.Combine( SolutionDir, ".vs",