Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix AccountLayout, also MSBuildProjectService for blazor projects. #3113

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Versions.DotNetScaffold.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>9.0.0</VersionPrefix>
<VersionPrefix>9.0.1</VersionPrefix>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
<PreReleaseVersionIteration>10</PreReleaseVersionIteration>
<IncludeSourceRevisionInInformationalVersion>False</IncludeSourceRevisionInInformationalVersion>
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-scaffold-all.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set VERSION=10.0.0-dev
set VERSION=9.0.1-dev
set DEFAULT_NUPKG_PATH=%userprofile%/.nuget/packages
set SRC_DIR=%cd%
set NUPKG=artifacts/packages/Debug/Shipping/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.DotNet.Scaffolding.Roslyn.Services;
public class MSBuildProjectService : IMSBuildProjectService
{
private readonly string _projectPath;
private Build.Evaluation.Project? _project;
private Project? _project;
private bool _initialized;
private readonly object _initLock = new();
public MSBuildProjectService(string projectPath)
Expand Down Expand Up @@ -53,13 +53,12 @@ private void Initialize(bool refresh = false)
return;
}

//try loading MSBuild project the faster way.
_project = new Project(_projectPath, null, null, new Build.Evaluation.ProjectCollection(), ProjectLoadSettings.IgnoreMissingImports);
//if fails, use the longer way using GLobalProjectCollection.
if (_project is null)
try
{
_project = ProjectCollection.GlobalProjectCollection.LoadProject(_projectPath);
deepchoudhery marked this conversation as resolved.
Show resolved Hide resolved
//try loading MSBuild project the faster way.
_project = new Project(_projectPath, null, null, new ProjectCollection(), ProjectLoadSettings.IgnoreMissingImports);
}
catch (Exception) { }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ public override async Task<bool> ExecuteAsync(ScaffolderContext context, Cancell

string identityNamespace = string.Empty;
string userClassNamespace = string.Empty;
string identityLayoutNamespace = string.Empty;
var projectName = Path.GetFileNameWithoutExtension(settings.Project);
if (!string.IsNullOrEmpty(projectName))
{
identityNamespace = settings.BlazorScenario ? $"{projectName}.Components.Account" : $"{projectName}.Areas.Identity";
identityLayoutNamespace = settings.BlazorScenario ? $"{projectName}.Components.Layout.MainLayout" : string.Empty;
userClassNamespace = $"{projectName}.Data";
}

Expand All @@ -176,6 +178,7 @@ public override async Task<bool> ExecuteAsync(ScaffolderContext context, Cancell
IdentityNamespace = identityNamespace,
UserClassName = AspNetConstants.Identity.UserClassName,
UserClassNamespace = userClassNamespace,
IdentityLayoutNamespace = identityLayoutNamespace,
BaseOutputPath = projectDirectory,
Overwrite = settings.Overwrite
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public virtual void Initialize()
}
else
{
this.Error("The type \'Microsoft.DotNet.Tools.Scaffold.AspNet.Models.BlazorIdentityModel\' of t" +
"he parameter \'Model\' did not match the type of the data passed to the template.");
this.Error("The type \'Microsoft.DotNet.Tools.Scaffold.AspNet.Models.IdentityModel\' of the par" +
"ameter \'Model\' did not match the type of the data passed to the template.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
@using <#= Model.UserClassNamespace #>
@inherits LayoutComponentBase
<#
if (!string.IsNullOrEmpty(Model.BlazorLayoutNamespace))
if (!string.IsNullOrEmpty(Model.IdentityLayoutNamespace))
{
#>@layout <#= Model.BlazorLayoutNamespace #>
#>@layout <#= Model.IdentityLayoutNamespace #>
<#} #>
@inject NavigationManager NavigationManager

Expand Down