Skip to content

Commit

Permalink
Demo for using a NuGet package (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
isc30 authored May 7, 2020
1 parent 24c17a0 commit 481390e
Show file tree
Hide file tree
Showing 22 changed files with 223 additions and 105 deletions.
11 changes: 11 additions & 0 deletions demo/BlazorLazyLoading.Components.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<!-- Use Local NuGet package -->
<ItemGroup Condition="$(BLLUseLocalNugetPackages)">
<PackageReference Include="BlazorLazyLoading.Components" Version="$(BLLVersion)" />
</ItemGroup>

<!-- Use Project reference -->
<ItemGroup Condition="!$(BLLUseLocalNugetPackages)">
<ProjectReference Include="$(MSBuildThisFileDirectory)..\nuget\BlazorLazyLoading.Components\BlazorLazyLoading.Components.csproj" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions demo/BlazorLazyLoading.Module.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<!-- Use Local NuGet package -->
<ItemGroup Condition="$(BLLUseLocalNugetPackages)">
<PackageReference Include="BlazorLazyLoading.Module" Version="$(BLLVersion)" PrivateAssets="all" />
</ItemGroup>

<!-- Use Project reference -->
<ItemGroup Condition="!$(BLLUseLocalNugetPackages)">
<ProjectReference Include="$(MSBuildThisFileDirectory)..\nuget\BlazorLazyLoading.Module\BlazorLazyLoading.Module.csproj" PrivateAssets="all" />
</ItemGroup>
<Import Condition="!$(BLLUseLocalNugetPackages)" Project="$(MSBuildThisFileDirectory)..\nuget\BlazorLazyLoading.Module\build\BlazorLazyLoading.Module.props" />
<Import Condition="!$(BLLUseLocalNugetPackages)" Project="$(MSBuildThisFileDirectory)..\nuget\BlazorLazyLoading.Module\build\BlazorLazyLoading.Module.targets" />
</Project>
11 changes: 11 additions & 0 deletions demo/BlazorLazyLoading.Server.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<!-- Use Local NuGet package -->
<ItemGroup Condition="$(BLLUseLocalNugetPackages)">
<PackageReference Include="BlazorLazyLoading.Server" Version="$(BLLVersion)" PrivateAssets="all" />
</ItemGroup>

<!-- Use Project reference -->
<ItemGroup Condition="!$(BLLUseLocalNugetPackages)">
<ProjectReference Include="$(MSBuildThisFileDirectory)..\nuget\BlazorLazyLoading.Server\BlazorLazyLoading.Server.csproj" PrivateAssets="all" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions demo/BlazorLazyLoading.Wasm.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<!-- Use Local NuGet package -->
<ItemGroup Condition="$(BLLUseLocalNugetPackages)">
<PackageReference Include="BlazorLazyLoading.Wasm" Version="$(BLLVersion)" PrivateAssets="all" />
</ItemGroup>

<!-- Use Project reference -->
<ItemGroup Condition="!$(BLLUseLocalNugetPackages)">
<ProjectReference Include="$(MSBuildThisFileDirectory)..\nuget\BlazorLazyLoading.Wasm\BlazorLazyLoading.Wasm.csproj" PrivateAssets="all" />
</ItemGroup>
</Project>
24 changes: 24 additions & 0 deletions demo/Demo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LazyAreas", "LazyAreas", "{
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{DB1AE536-72C2-4CCD-A7D9-0A79AAEEDA54}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LazyComponentFromNuget", "LazyAreas\LazyComponentFromNuget\LazyComponentFromNuget.csproj", "{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Imports", "Imports", "{7B174F1E-2091-4D48-9111-B52531C1B865}"
ProjectSection(SolutionItems) = preProject
BlazorLazyLoading.Components.props = BlazorLazyLoading.Components.props
BlazorLazyLoading.Module.props = BlazorLazyLoading.Module.props
BlazorLazyLoading.Server.props = BlazorLazyLoading.Server.props
BlazorLazyLoading.Wasm.props = BlazorLazyLoading.Wasm.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -155,6 +165,18 @@ Global
{DB1AE536-72C2-4CCD-A7D9-0A79AAEEDA54}.Release|x64.Build.0 = Release|Any CPU
{DB1AE536-72C2-4CCD-A7D9-0A79AAEEDA54}.Release|x86.ActiveCfg = Release|Any CPU
{DB1AE536-72C2-4CCD-A7D9-0A79AAEEDA54}.Release|x86.Build.0 = Release|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Debug|x64.Build.0 = Debug|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Debug|x86.ActiveCfg = Debug|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Debug|x86.Build.0 = Debug|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Release|Any CPU.Build.0 = Release|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Release|x64.ActiveCfg = Release|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Release|x64.Build.0 = Release|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Release|x86.ActiveCfg = Release|Any CPU
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -171,6 +193,8 @@ Global
{E503BF43-DE57-4DB6-AF93-A5F765C94154} = {2587AE99-7624-47E4-B6B8-79EC67346F67}
{566D14F1-B2FB-463C-A627-C5EB23B763B7} = {2587AE99-7624-47E4-B6B8-79EC67346F67}
{DB1AE536-72C2-4CCD-A7D9-0A79AAEEDA54} = {2587AE99-7624-47E4-B6B8-79EC67346F67}
{A4D17AA8-D918-45FD-9CCA-3FC5ECCDBD97} = {566D14F1-B2FB-463C-A627-C5EB23B763B7}
{7B174F1E-2091-4D48-9111-B52531C1B865} = {2587AE99-7624-47E4-B6B8-79EC67346F67}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B979A335-AE81-406A-AADA-F236549D23D3}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.2" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Faso.Blazor.SpinKit" Version="1.0.1" />
</ItemGroup>

<Import Project="../../BlazorLazyLoading.Components.props" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@page "/lazy-component-from-nuget"

<h1>Lazy Component from NuGet</h1>
<p>
The following component is rendered from a nuget package (Faso.Blazor.SpinKit in this case).
The nuget DLL will only be loaded when opening this page for the first time. Please check the network tab :)
</p>

@*
Works fine out of the box
*@
<Faso.Blazor.SpinKit.SpinKitWave />

@*
Requires the Module to have:
+ <BLLManifestAssemblies Include="Faso.Blazor.SpinKit" />
*@
@*<Lazy Name="Faso.Blazor.SpinKit.SpinKitWave" />*@
7 changes: 7 additions & 0 deletions demo/LazyAreas/LazyComponentFromNuget/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop

@using BlazorLazyLoading
2 changes: 2 additions & 0 deletions demo/LazyAreas/LazyComponentFromNuget/wwwroot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_lazy/
_lazy.json
10 changes: 1 addition & 9 deletions demo/Logger/Logger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.2" />
</ItemGroup>

<!-- Use Local NuGet package -->
<ItemGroup Condition="$(BLLUseLocalNugetPackages)">
<PackageReference Include="BlazorLazyLoading.Components" Version="$(BLLVersion)" />
</ItemGroup>

<!-- Use Project reference -->
<ItemGroup Condition="!$(BLLUseLocalNugetPackages)">
<ProjectReference Include="..\..\nuget\BlazorLazyLoading.Components\BlazorLazyLoading.Components.csproj" />
</ItemGroup>
<Import Project="../BlazorLazyLoading.Components.props" />

<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
Expand Down
1 change: 1 addition & 0 deletions demo/ModulesHost/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/
20 changes: 8 additions & 12 deletions demo/ModulesHost/ModulesHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<!-- Modules -->
<ItemGroup>
<ProjectReference Include="..\Logger\Logger.csproj" Name="Logger" />
</ItemGroup>

<!-- Use Local NuGet package -->
<ItemGroup Condition="$(BLLUseLocalNugetPackages)">
<PackageReference Include="BlazorLazyLoading.Module" Version="$(BLLVersion)" PrivateAssets="all" />
<ProjectReference Include="..\Logger\Logger.csproj" />
<ProjectReference Include="..\LazyAreas\LazyComponentFromNuget\LazyComponentFromNuget.csproj" />
</ItemGroup>

<!-- Use Project reference -->
<ItemGroup Condition="!$(BLLUseLocalNugetPackages)">
<ProjectReference Include="..\..\nuget\BlazorLazyLoading.Module\BlazorLazyLoading.Module.csproj" PrivateAssets="all" />
<!-- Extra Assemblies in the Manifest -->
<ItemGroup>
<BLLManifestAssemblies Include="Logger" />
<BLLManifestAssemblies Include="LazyComponentFromNuget" />
</ItemGroup>
<Import Condition="!$(BLLUseLocalNugetPackages)" Project="..\..\nuget\BlazorLazyLoading.Module\build\BlazorLazyLoading.Module.props" />
<Import Condition="!$(BLLUseLocalNugetPackages)" Project="..\..\nuget\BlazorLazyLoading.Module\build\BlazorLazyLoading.Module.targets" />

<Import Project="../BlazorLazyLoading.Module.props" />

</Project>
10 changes: 1 addition & 9 deletions demo/ServerHost/ServerHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<!-- Use Local NuGet package -->
<ItemGroup Condition="$(BLLUseLocalNugetPackages)">
<PackageReference Include="BlazorLazyLoading.Server" Version="$(BLLVersion)" PrivateAssets="all" />
</ItemGroup>

<!-- Use Project reference -->
<ItemGroup Condition="!$(BLLUseLocalNugetPackages)">
<ProjectReference Include="..\..\nuget\BlazorLazyLoading.Server\BlazorLazyLoading.Server.csproj" PrivateAssets="all" />
</ItemGroup>
<Import Project="../BlazorLazyLoading.Server.props" />

<!-- Extra dependencies -->
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions demo/WasmHost/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
</li>
<li class="nav-item">
<NavLink class="nav-link" href="counter">
<span class="oi oi-plus" aria-hidden="true"></span> Counter
<span class="oi oi-plus" aria-hidden="true"></span> &lt;Lazy /&gt;
</NavLink>
</li>
<li class="nav-item">
<NavLink class="nav-link" href="fetchdata">
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch Data
<NavLink class="nav-link" href="lazy-component-from-nuget">
<span class="oi oi-plus" aria-hidden="true"></span> Lazy Component from Nuget
</NavLink>
</li>
<li class="nav-item">
Expand Down
10 changes: 1 addition & 9 deletions demo/WasmHost/WasmHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@
<BlazorLinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>

<!-- Use Local NuGet package -->
<ItemGroup Condition="$(BLLUseLocalNugetPackages)">
<PackageReference Include="BlazorLazyLoading.Wasm" Version="$(BLLVersion)" PrivateAssets="all" />
</ItemGroup>

<!-- Use Project reference -->
<ItemGroup Condition="!$(BLLUseLocalNugetPackages)">
<ProjectReference Include="..\..\nuget\BlazorLazyLoading.Wasm\BlazorLazyLoading.Wasm.csproj" PrivateAssets="all" />
</ItemGroup>
<Import Project="../BlazorLazyLoading.Wasm.props" />

<!-- Extra dependencies -->
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
<Project>

<PropertyGroup>
<BLLGenerateLazyManifest Condition="'$(BLLGenerateLazyManifest)' == ''">true</BLLGenerateLazyManifest>
<BLLGenerateManifest Condition="'$(BLLGenerateManifest)' == ''">true</BLLGenerateManifest>
<RestoreProjectStyle Condition="'$(RestoreProjectStyle)' == ''">PackageReference</RestoreProjectStyle>
<CopyLocalLockFileAssemblies Condition="'$(CopyLocalLockFileAssemblies)' == ''">$(BLLGenerateLazyManifest)</CopyLocalLockFileAssemblies>
<CopyLocalLockFileAssemblies Condition="'$(CopyLocalLockFileAssemblies)' == ''">$(BLLGenerateManifest)</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
<BLLManifestGeneratorAssemblyNames Remove="*" />
<BLLManifestGeneratorAssemblyPaths Remove="*" />

<BLLManifestGeneratorAssemblyNames Include="$(MSBuildProjectName)" />
<BLLManifestGeneratorAssemblyPaths Include="$(_BLLNugetPackageBuildBinDirectory)" />
<BLLManifestAssemblies Include="$(MSBuildProjectName)" />
<BLLManifestAssemblyPaths Include="$(_BLLNugetPackageBuildBinDirectory)" />
</ItemGroup>

<PropertyGroup>
<_BLLNugetPackageBuildBinDirectory>$(MSBuildThisFileDirectory)../build/bin/</_BLLNugetPackageBuildBinDirectory>

<ModuleLazyDirectoryName>_lazy</ModuleLazyDirectoryName>
<ModuleLazyManifestFile>_lazy.json</ModuleLazyManifestFile>
<ModuleWwwRootDirectory>$(MSBuildProjectDirectory)/wwwroot/</ModuleWwwRootDirectory>
<ModuleLazyDirectory>$(ModuleWwwRootDirectory)$(ModuleLazyDirectoryName)/</ModuleLazyDirectory>
<ModuleManifestPath>$(ModuleWwwRootDirectory)$(ModuleLazyManifestFile)</ModuleManifestPath>
<_BLLModuleLazyDirectoryName>_lazy</_BLLModuleLazyDirectoryName>
<_BLLModuleLazyManifestFile>_lazy.json</_BLLModuleLazyManifestFile>
<_BLLModuleWwwRootDirectory>$(MSBuildProjectDirectory)/wwwroot/</_BLLModuleWwwRootDirectory>
<_BLLModuleLazyDirectory>$(_BLLModuleWwwRootDirectory)$(_BLLModuleLazyDirectoryName)/</_BLLModuleLazyDirectory>
<_BLLModuleManifestPath>$(_BLLModuleWwwRootDirectory)$(_BLLModuleLazyManifestFile)</_BLLModuleManifestPath>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

<Target Name="CreateGitIgnore" BeforeTargets="PrepareForBuild">
<WriteLinesToFile
Condition="!Exists('$(ModuleWwwRootDirectory).gitignore')"
File="$(ModuleWwwRootDirectory).gitignore"
Lines="$(ModuleLazyDirectoryName)/;$(ModuleLazyManifestFile)"/>
Condition="!Exists('$(_BLLModuleWwwRootDirectory).gitignore')"
File="$(_BLLModuleWwwRootDirectory).gitignore"
Lines="$(_BLLModuleLazyDirectoryName)/;$(_BLLModuleLazyManifestFile)"/>
</Target>

<Target Name="CleanBin" BeforeTargets="Clean;Rebuild;Build">
<ItemGroup>
<FilesToDelete Include="$(ModuleLazyDirectory)**/*.*" />
<FilesToDelete Include="$(ModuleManifestPath)" />
<_FilesToDelete Include="$(_BLLModuleLazyDirectory)**/*.*" />
<_FilesToDelete Include="$(_BLLModuleManifestPath)" />
</ItemGroup>

<RemoveDir Directories="$(ModuleLazyDirectory)" />
<Delete Files="@(FilesToDelete)" />
<RemoveDir Directories="$(_BLLModuleLazyDirectory)" />
<Delete Files="@(_FilesToDelete)" />
</Target>

<!-- Ensure all DLLs and PDBs are available -->
Expand All @@ -32,32 +32,28 @@

<Copy
SourceFiles="@(OutputFiles)"
DestinationFolder="$(ModuleLazyDirectory)"
DestinationFolder="$(_BLLModuleLazyDirectory)"
OverwriteReadOnlyFiles="true"
SkipUnchangedFiles="false" />

</Target>

<!-- Create Lazy Manifest -->

<UsingTask TaskName="GenerateManifest" AssemblyFile="$(_BLLNugetPackageBuildBinDirectory)ManifestGenerator.dll" />

<Target Name="GenerateManifest" AfterTargets="CopyDependencies" Condition="$(BLLGenerateLazyManifest)">
<Target Name="GenerateManifest" AfterTargets="CopyDependencies" Condition="$(BLLGenerateManifest)">

<PropertyGroup>
<ProjectOutDir>$(MSBuildProjectDirectory)/$(OutDir)</ProjectOutDir>
</PropertyGroup>

<ItemGroup>
<BLLManifestGeneratorAssemblyNames Include="@(ProjectReference->'%(Name)')" />
</ItemGroup>

<Message Importance="normal" Text="BLLManifestGeneratorAssemblyNames: @(BLLManifestGeneratorAssemblyNames)" />
<Message Importance="normal" Text="Generating manifest for: @(BLLManifestAssemblies)" />

<GenerateManifest
AssemblyNames="@(BLLManifestGeneratorAssemblyNames)"
AssemblyPaths="$(ProjectOutDir);@(BLLManifestGeneratorAssemblyPaths)"
ManifestOutputPath="$(ModuleManifestPath)" />
AssemblyNames="@(BLLManifestAssemblies)"
AssemblyPaths="$(ProjectOutDir);@(BLLManifestAssemblyPaths)"
ManifestOutputPath="$(_BLLModuleManifestPath)" />

</Target>

Expand Down
Loading

0 comments on commit 481390e

Please sign in to comment.