Skip to content
Open
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 scripts/install-scaffold.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set VERSION=20.0.0-dev
set VERSION=20.1.0-dev
set DEFAULT_NUPKG_PATH=%userprofile%/.nuget/packages
set SRC_DIR=%cd%
set NUPKG=artifacts/packages/Debug/Shipping/
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-scaffold.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION=20.0.0-dev
VERSION=20.1.0-dev
DEFAULT_NUPKG_PATH=~/.nuget/packages
SRC_DIR=$(pwd)
echo $SRC_DIR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ internal class IdentityModel
/// Gets or sets a value indicating whether to overwrite existing files.
/// </summary>
public bool Overwrite { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the target project is a Razor Pages project.
/// Used to determine the correct layout path in _ViewStart.cshtml.
/// </summary>
public bool IsRazorPages { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public override async Task<bool> ExecuteAsync(ScaffolderContext context, Cancell
userClassNamespace = $"{projectName}.Data";
}

bool isRazorPages = Directory.Exists(Path.Combine(projectDirectory, "Pages"));
IdentityModel scaffoldingModel = new()
{
ProjectInfo = projectInfo,
Expand All @@ -226,7 +227,8 @@ public override async Task<bool> ExecuteAsync(ScaffolderContext context, Cancell
UserClassNamespace = userClassNamespace,
IdentityLayoutNamespace = identityLayoutNamespace,
BaseOutputPath = projectDirectory,
Overwrite = settings.Overwrite
Overwrite = settings.Overwrite,
IsRazorPages = isRazorPages
};

if (scaffoldingModel.ProjectInfo is not null && scaffoldingModel.ProjectInfo.CodeService is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public partial class _ViewStart : _ViewStartBase
/// </summary>
public virtual string TransformText()
{
this.Write("@{\r\n Layout = \"/Pages/Shared/_Layout.cshtml\";\r\n}\r\n");
this.Write("@{\r\n Layout = \"");
this.Write(this.ToStringHelper.ToStringWithCulture(Model.IsRazorPages ? "/Pages/Shared/_Layout.cshtml" : "/Views/Shared/_Layout.cshtml"));
this.Write("\";\r\n}\r\n");
return this.GenerationEnvironment.ToString();
}
private global::Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost hostValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Linq" #>
@{
Layout = "/Pages/Shared/_Layout.cshtml";
Layout = "<#= Model.IsRazorPages ? "/Pages/Shared/_Layout.cshtml" : "/Views/Shared/_Layout.cshtml" #>";
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public partial class _ViewStart : _ViewStartBase
/// </summary>
public virtual string TransformText()
{
this.Write("@{\r\n Layout = \"/Pages/Shared/_Layout.cshtml\";\r\n}\r\n");
this.Write("@{\r\n Layout = \"");
this.Write(this.ToStringHelper.ToStringWithCulture(Model.IsRazorPages ? "/Pages/Shared/_Layout.cshtml" : "/Views/Shared/_Layout.cshtml"));
this.Write("\";\r\n}\r\n");
return this.GenerationEnvironment.ToString();
}
private global::Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost hostValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Linq" #>
@{
Layout = "/Pages/Shared/_Layout.cshtml";
Layout = "<#= Model.IsRazorPages ? "/Pages/Shared/_Layout.cshtml" : "/Views/Shared/_Layout.cshtml" #>";
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public partial class _ViewStart : _ViewStartBase
/// </summary>
public virtual string TransformText()
{
this.Write("@{\r\n Layout = \"/Pages/Shared/_Layout.cshtml\";\r\n}\r\n");
this.Write("@{\r\n Layout = \"");
this.Write(this.ToStringHelper.ToStringWithCulture(Model.IsRazorPages ? "/Pages/Shared/_Layout.cshtml" : "/Views/Shared/_Layout.cshtml"));
this.Write("\";\r\n}\r\n");
return this.GenerationEnvironment.ToString();
}
private global::Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost hostValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Linq" #>
@{
Layout = "/Pages/Shared/_Layout.cshtml";
Layout = "<#= Model.IsRazorPages ? "/Pages/Shared/_Layout.cshtml" : "/Views/Shared/_Layout.cshtml" #>";
}