Inject MSBuild properties into templates during build
This commit is contained in:
parent
ce3c79e051
commit
ce8088f9a3
|
|
@ -12,6 +12,7 @@
|
||||||
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true'">
|
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true'">
|
||||||
$(RestoreSources);
|
$(RestoreSources);
|
||||||
https://api.nuget.org/v3/index.json;
|
https://api.nuget.org/v3/index.json;
|
||||||
|
https://dotnet.myget.org/f/blazor-dev/api/v3/index.json;
|
||||||
</RestoreSources>
|
</RestoreSources>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# We only track the .template.config.src items in source control
|
||||||
|
# The .template.config files are generated on build
|
||||||
|
content/**/.template.config/
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
<!--
|
<PropertyGroup>
|
||||||
Left mostly blank to avoid sharing config with the build for the main repo.
|
<TemplateBlazorPackageVersion>0.2.0-preview1-10195</TemplateBlazorPackageVersion>
|
||||||
For example, we want the templates to declare their own independent package restore sources.
|
</PropertyGroup>
|
||||||
-->
|
|
||||||
|
|
||||||
<Import Project="../../version.props" />
|
<Import Project="..\..\Directory.Build.props" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard20</TargetFramework>
|
<TargetFramework>netstandard20</TargetFramework>
|
||||||
<NuspecFile>Microsoft.AspNetCore.Blazor.Templates.nuspec</NuspecFile>
|
<NuspecFile>Microsoft.AspNetCore.Blazor.Templates.nuspec</NuspecFile>
|
||||||
|
|
@ -7,4 +7,38 @@
|
||||||
<IncludeBuildOutput>False</IncludeBuildOutput>
|
<IncludeBuildOutput>False</IncludeBuildOutput>
|
||||||
<NoWarn>2008</NoWarn>
|
<NoWarn>2008</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="TransformTemplateConfigs" BeforeTargets="CoreBuild" DependsOnTargets="SetTemplateJsonSymbolReplacements">
|
||||||
|
<!--
|
||||||
|
For each template, copy its '.template.config.src' directory to '.template.config',
|
||||||
|
removing any earlier output at that location
|
||||||
|
-->
|
||||||
|
<ItemGroup>
|
||||||
|
<_TemplateConfigMainFile Include="content\**\.template.config.src\template.json" />
|
||||||
|
<_TemplateConfigDir Include="@(_TemplateConfigMainFile->'$([System.IO.Path]::GetDirectoryName('%(_TemplateConfigMainFile.FullPath)'))')" />
|
||||||
|
<_TemplateConfigFileToCopy Include="%(_TemplateConfigDir.Identity)\**\*.*">
|
||||||
|
<DestDir>$([System.IO.Path]::GetDirectoryName('%(_TemplateConfigDir.Identity)'))\.template.config\</DestDir>
|
||||||
|
</_TemplateConfigFileToCopy>
|
||||||
|
</ItemGroup>
|
||||||
|
<RemoveDir Directories="%(_TemplateConfigFileToCopy.DestDir)" />
|
||||||
|
<Copy SourceFiles="%(_TemplateConfigFileToCopy.Identity)" DestinationFolder="%(_TemplateConfigFileToCopy.DestDir)" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Modify the .json files in the .template.config dirs to stamp MSBuild properties into them
|
||||||
|
-->
|
||||||
|
<ItemGroup>
|
||||||
|
<GeneratedContent Include="@(_TemplateConfigFileToCopy->WithMetadataValue('Extension','.json'))">
|
||||||
|
<OutputPath>%(DestDir)%(RecursiveDir)%(Filename)%(Extension)</OutputPath>
|
||||||
|
<Properties>$(GeneratedContentProperties)</Properties>
|
||||||
|
</GeneratedContent>
|
||||||
|
</ItemGroup>
|
||||||
|
<Sdk_GenerateFileFromTemplate
|
||||||
|
TemplateFile="%(GeneratedContent.Identity)"
|
||||||
|
Properties="%(GeneratedContent.Properties)"
|
||||||
|
OutputPath="%(GeneratedContent.OutputPath)">
|
||||||
|
|
||||||
|
<Output TaskParameter="OutputPath" ItemName="FileWrites" />
|
||||||
|
<Output TaskParameter="OutputPath" ItemName="Content" />
|
||||||
|
</Sdk_GenerateFileFromTemplate>
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<files>
|
<files>
|
||||||
<file
|
<file
|
||||||
src="content/**/*"
|
src="content/**/*"
|
||||||
exclude="content/BlazorHosted.CSharp.Client/Properties/launchSettings.json;content/BlazorHosted.CSharp.Server/Properties/launchSettings.json;**/node_modules/**;**/bin/**;**/obj/**;**/*.user;**/.vs/**;**/.vscode/**;content/Directory.Build.*"
|
exclude="content/BlazorHosted.CSharp.Client/Properties/launchSettings.json;content/BlazorHosted.CSharp.Server/Properties/launchSettings.json;**/node_modules/**;**/bin/**;**/obj/**;**/*.user;**/.vs/**;**/.vscode/**;content/Directory.Build.*;**/.template.config.src/**"
|
||||||
target="Content" />
|
target="Content" />
|
||||||
</files>
|
</files>
|
||||||
</package>
|
</package>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,27 @@
|
||||||
<Project>
|
<Project>
|
||||||
<Target Name="SetPackageProperties" BeforeTargets="GenerateNuspec">
|
<Target Name="SetPackageProperties" BeforeTargets="GenerateNuspec">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
<!-- Properties here are injected into the .nuspec file that is bundled into the package -->
|
||||||
<NuspecProperties>
|
<NuspecProperties>
|
||||||
$(NuspecProperties);
|
$(NuspecProperties);
|
||||||
version=$(PackageVersion);
|
version=$(PackageVersion);
|
||||||
</NuspecProperties>
|
</NuspecProperties>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="SetTemplateJsonSymbolReplacements">
|
||||||
|
<PropertyGroup>
|
||||||
|
<IncludeCustomRestoreSourcesValue Condition="'$(IsFinalBuild)' == 'true'">false</IncludeCustomRestoreSourcesValue>
|
||||||
|
<IncludeCustomRestoreSourcesValue Condition="'$(IsFinalBuild)' != 'true'">true</IncludeCustomRestoreSourcesValue>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Properties here will be injected into the template config *.json files
|
||||||
|
during the build, replacing tokens of the form ${PropertyName}
|
||||||
|
-->
|
||||||
|
<GeneratedContentProperties>
|
||||||
|
IncludeCustomRestoreSources=$(IncludeCustomRestoreSourcesValue);
|
||||||
|
TemplateBlazorVersion=$(PackageVersion);
|
||||||
|
</GeneratedContentProperties>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
|
@ -86,6 +86,19 @@
|
||||||
"type": "bind",
|
"type": "bind",
|
||||||
"binding": "HostIdentifier"
|
"binding": "HostIdentifier"
|
||||||
},
|
},
|
||||||
|
"IncludeCustomRestoreSourcesSymbol": {
|
||||||
|
"type": "parameter",
|
||||||
|
"datatype": "bool",
|
||||||
|
"description": "If set, includes restore sources for the Blazor MyGet feed.",
|
||||||
|
"defaultValue": "${IncludeCustomRestoreSources}"
|
||||||
|
},
|
||||||
|
"TemplateBlazorVersionSymbol": {
|
||||||
|
"type": "parameter",
|
||||||
|
"datatype": "string",
|
||||||
|
"description": "Specifies which version of Blazor packages to use.",
|
||||||
|
"replaces": "$(TemplateBlazorPackageVersion)",
|
||||||
|
"defaultValue": "${TemplateBlazorVersion}"
|
||||||
|
},
|
||||||
"skipRestore": {
|
"skipRestore": {
|
||||||
"type": "parameter",
|
"type": "parameter",
|
||||||
"datatype": "bool",
|
"datatype": "bool",
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
|
<RestoreSources Condition="'$(IncludeCustomRestoreSourcesSymbol)'=='true'">
|
||||||
<!-- This custom package feed is required only when using nightly builds of Blazor -->
|
$(RestoreSources);
|
||||||
<RestoreSources>$(RestoreSources);https://dotnet.myget.org/f/blazor-dev/api/v3/index.json</RestoreSources>
|
https://api.nuget.org/v3/index.json;
|
||||||
|
https://dotnet.myget.org/f/blazor-dev/api/v3/index.json;
|
||||||
|
</RestoreSources>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.0-preview2-final" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.0-preview2-final" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.2.0-preview1-10195" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.2.0-preview1-10195" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,21 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
<RestoreSources Condition="'$(IncludeCustomRestoreSourcesSymbol)'=='true'">
|
||||||
<!-- This custom package feed is required only when using nightly builds of Blazor -->
|
$(RestoreSources);
|
||||||
<RestoreSources>$(RestoreSources);https://dotnet.myget.org/f/blazor-dev/api/v3/index.json</RestoreSources>
|
https://api.nuget.org/v3/index.json;
|
||||||
|
https://dotnet.myget.org/f/blazor-dev/api/v3/index.json;
|
||||||
|
</RestoreSources>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(Framework)' == 'netcoreapp2.1'">
|
<ItemGroup Condition="'$(Framework)' == 'netcoreapp2.1'">
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0-preview2-final" />
|
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0-preview2-final" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="0.2.0-preview1-10195" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Condition="'$(Framework)' == 'netcoreapp2.0'">
|
<ItemGroup Condition="'$(Framework)' == 'netcoreapp2.0'">
|
||||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="0.2.0-preview1-10195" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
|
@ -47,6 +47,19 @@
|
||||||
"type": "bind",
|
"type": "bind",
|
||||||
"binding": "HostIdentifier"
|
"binding": "HostIdentifier"
|
||||||
},
|
},
|
||||||
|
"IncludeCustomRestoreSourcesSymbol": {
|
||||||
|
"type": "parameter",
|
||||||
|
"datatype": "bool",
|
||||||
|
"description": "If set, includes restore sources for the Blazor MyGet feed.",
|
||||||
|
"defaultValue": "${IncludeCustomRestoreSources}"
|
||||||
|
},
|
||||||
|
"TemplateBlazorVersionSymbol": {
|
||||||
|
"type": "parameter",
|
||||||
|
"datatype": "string",
|
||||||
|
"description": "Specifies which version of Blazor packages to use.",
|
||||||
|
"replaces": "$(TemplateBlazorPackageVersion)",
|
||||||
|
"defaultValue": "${TemplateBlazorVersion}"
|
||||||
|
},
|
||||||
"skipRestore": {
|
"skipRestore": {
|
||||||
"type": "parameter",
|
"type": "parameter",
|
||||||
"datatype": "bool",
|
"datatype": "bool",
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<OutputType>library</OutputType>
|
<OutputType>library</OutputType>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
|
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
|
||||||
|
<RestoreSources Condition="'$(IncludeCustomRestoreSourcesSymbol)'=='true'">
|
||||||
<!-- This custom package feed is required only when using nightly builds of Blazor -->
|
$(RestoreSources);
|
||||||
<RestoreSources>https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;$(RestoreSources)</RestoreSources>
|
https://api.nuget.org/v3/index.json;
|
||||||
|
https://dotnet.myget.org/f/blazor-dev/api/v3/index.json;
|
||||||
|
</RestoreSources>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -19,8 +21,8 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.0-preview2-final" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.0-preview2-final" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.2.0-preview1-10195" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.2.0-preview1-10195" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
|
@ -65,6 +65,19 @@
|
||||||
},
|
},
|
||||||
"replaces": "61501"
|
"replaces": "61501"
|
||||||
},
|
},
|
||||||
|
"IncludeCustomRestoreSourcesSymbol": {
|
||||||
|
"type": "parameter",
|
||||||
|
"datatype": "bool",
|
||||||
|
"description": "If set, includes restore sources for the Blazor MyGet feed.",
|
||||||
|
"defaultValue": "${IncludeCustomRestoreSources}"
|
||||||
|
},
|
||||||
|
"TemplateBlazorVersionSymbol": {
|
||||||
|
"type": "parameter",
|
||||||
|
"datatype": "string",
|
||||||
|
"description": "Specifies which version of Blazor packages to use.",
|
||||||
|
"replaces": "$(TemplateBlazorPackageVersion)",
|
||||||
|
"defaultValue": "${TemplateBlazorVersion}"
|
||||||
|
},
|
||||||
"skipRestore": {
|
"skipRestore": {
|
||||||
"type": "parameter",
|
"type": "parameter",
|
||||||
"datatype": "bool",
|
"datatype": "bool",
|
||||||
|
|
@ -1,19 +1,21 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<RunCommand>dotnet</RunCommand>
|
<RunCommand>dotnet</RunCommand>
|
||||||
<RunArguments>blazor serve</RunArguments>
|
<RunArguments>blazor serve</RunArguments>
|
||||||
|
<RestoreSources Condition="'$(IncludeCustomRestoreSourcesSymbol)'=='true'">
|
||||||
<!-- This custom package feed is required only when using nightly builds of Blazor -->
|
$(RestoreSources);
|
||||||
<RestoreSources>$(RestoreSources);https://dotnet.myget.org/f/blazor-dev/api/v3/index.json</RestoreSources>
|
https://api.nuget.org/v3/index.json;
|
||||||
|
https://dotnet.myget.org/f/blazor-dev/api/v3/index.json;
|
||||||
|
</RestoreSources>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.0-preview2-final" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.0-preview2-final" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.2.0-preview1-10195" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.2.0-preview1-10195" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="0.2.0-preview1-10195" />
|
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="$(TemplateBlazorPackageVersion)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue