Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion Microsoft.AspNetCore.SystemWebAdapters.sln
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModulesLibrary", "samples\M
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModulesFramework", "samples\Modules\ModulesFramework\ModulesFramework.csproj", "{B262AD69-11F0-4AE0-949A-AEAA2300C061}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModulesCore", "samples\Modules\ModulesCore\ModulesCore.csproj", "{F8B33C59-27CF-45DC-955C-2EBF9DA9DB7E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModulesCore", "samples\Modules\ModulesCore\ModulesCore.csproj", "{F8B33C59-27CF-45DC-955C-2EBF9DA9DB7E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SystemWebAdapters.NuGet.Tests", "test\Microsoft.AspNetCore.SystemWebAdapters.NuGet.Tests\Microsoft.AspNetCore.SystemWebAdapters.NuGet.Tests.csproj", "{17055F45-E79A-41EF-825E-0B2211433729}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -167,6 +169,10 @@ Global
{F8B33C59-27CF-45DC-955C-2EBF9DA9DB7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8B33C59-27CF-45DC-955C-2EBF9DA9DB7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8B33C59-27CF-45DC-955C-2EBF9DA9DB7E}.Release|Any CPU.Build.0 = Release|Any CPU
{17055F45-E79A-41EF-825E-0B2211433729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17055F45-E79A-41EF-825E-0B2211433729}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17055F45-E79A-41EF-825E-0B2211433729}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17055F45-E79A-41EF-825E-0B2211433729}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -200,6 +206,7 @@ Global
{5597A485-4D9B-4CE6-A489-DEBE9338450F} = {4ED7A31C-8DBE-4A32-A17A-D72794F9FE2C}
{B262AD69-11F0-4AE0-949A-AEAA2300C061} = {4ED7A31C-8DBE-4A32-A17A-D72794F9FE2C}
{F8B33C59-27CF-45DC-955C-2EBF9DA9DB7E} = {4ED7A31C-8DBE-4A32-A17A-D72794F9FE2C}
{17055F45-E79A-41EF-825E-0B2211433729} = {A1BDA50C-D70B-416C-97F1-74B0649797C5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DABA3C65-9D74-4EB6-9B1C-730328710EAD}
Expand Down
1 change: 1 addition & 0 deletions Microsoft.AspNetCore.SystemWebAdapters.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test\\Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests\\Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests.csproj",
"test\\Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.Tests\\Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.Tests.csproj",
"test\\Microsoft.AspNetCore.SystemWebAdapters.Tests\\Microsoft.AspNetCore.SystemWebAdapters.Tests.csproj",
"test\\Microsoft.AspNetCore.SystemWebAdapters.NuGet.Tests\\Microsoft.AspNetCore.SystemWebAdapters.NuGet.Tests.csproj",
"test\\Samples.MVCApp.Tests\\Samples.MVCApp.Tests.csproj",
"test\\Samples.RemoteAuth.Forms.Tests\\Samples.RemoteAuth.Forms.Tests.csproj"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<PropertyGroup />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="$(MSBuildThisFileDirectory)NuGetContentFiles.targets"/>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Project>

<!--
Add NuGet content to the build output if specified:
<PackageReference Include="..." CopyContent="true" ... />
-->
<Target Name="AddNugetContentFiles" BeforeTargets="AssignTargetPaths">
<PropertyGroup>
<EnableSystemWebAdapterNuGetWarnings Condition=" '$(EnableSystemWebAdapterNuGetWarnings)' == '' ">true</EnableSystemWebAdapterNuGetWarnings>
</PropertyGroup>

<!-- Identity PackageReference and paths to packages -->
<ItemGroup>
Copy link

@jeffkl jeffkl Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @rainersigwald so he can see this beautiful hackery 😄

<_PackageReferenceProperties Include="Pkg$([System.String]::Copy('%(PackageReference.Identity)').Replace('.','_'))">
<PackageName>%(PackageReference.Identity)</PackageName>
<CopyContent>%(PackageReference.CopyContent)</CopyContent>
</_PackageReferenceProperties>
<_PackageReferenceProperties Update="@(_PackageReferenceProperties)" PackageRootPath="$(%(_PackageReferenceProperties.Identity))" />
</ItemGroup>

<!-- Check for tools files -->
<ItemGroup>
<_ToolsFiles Include="%(_PackageReferenceProperties.PackageRootPath)/tools/*.ps1">
<PackageName>%(PackageName)</PackageName>
</_ToolsFiles>
<_ToolsPackage Include="%(_ToolsFiles.PackageName)" />
</ItemGroup>

<!-- Get content files-->
<ItemGroup>
<!-- Get all PackageReferences that have 'CopyContent' == 'true' -->
<_ContentPkgProperties Include="@(_PackageReferenceProperties)" Condition="'%(CopyContent)' == 'true'" />

<!-- Filter out packages that need GeneratePathProperty -->
<_ValidContentPkgProperties Include="@(_ContentPkgProperties)" Condition=" '%(PackageRootPath)' != '' " />
<_InvalidContentPkgProperties Include="@(_ContentPkgProperties)" Condition=" '%(PackageRootPath)' == '' " />
</ItemGroup>

<Warning
Condition=" '$(EnableSystemWebAdapterNuGetWarnings)' == 'true' AND '@(_InvalidContentPkgProperties)' != '' "
Text="%(_InvalidContentPkgProperties.PackageName) does not contain a tools directory and thus needs 'GeneratePathProperty' == 'true' " />

<Warning
Condition=" '$(EnableSystemWebAdapterNuGetWarnings)' == 'true' AND '@(_ToolsPackage)' != '' "
Text="%(_ToolsPackage.Identity) contains PowerShell files that may cause issues when using PackageReference" />

<ItemGroup Condition=" '@(_ValidContentPkgProperties)' != '' ">
<_NuGetContentFiles Include="%(_ValidContentPkgProperties.PackageRootPath)\Content\**\*">
<BasePath>%(_ValidContentPkgProperties.PackageRootPath)\Content</BasePath>
<PackageIdentity>%(_ValidContentPkgProperties.PackageName)</PackageIdentity>
</_NuGetContentFiles>

<Content Include="@(_NuGetContentFiles)">
<Link>$([MSBuild]::MakeRelative(%(_NuGetContentFiles.BasePath),%(_NuGetContentFiles.Identity)))</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<Reference Include="System.Web" />
</ItemGroup>

<ItemGroup>
<None Include="Build\*" Pack="true" PackagePath="Build\" />
</ItemGroup>

<Import Condition=" '$(TargetFramework)' == 'net6.0' " Project="Generated/GenerateApis.targets" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.IO;
using Xunit;

namespace Microsoft.AspNetCore.SystemWebAdapters.NuGet.Tests;

public class ContentFileTests
{
[Fact]
public void ContentFilesCopied()
{
// Arrange
var expected = new[]
{
"""Scripts\jquery-3.5.1-vsdoc.js""",
"""Scripts\jquery-3.5.1.js""",
"""Scripts\jquery-3.5.1.min.js""",
"""Scripts\jquery-3.5.1.min.map""",
"""Scripts\jquery-3.5.1.slim.js""",
"""Scripts\jquery-3.5.1.slim.min.js""",
"""Scripts\jquery-3.5.1.slim.min.map""",
};

// Act
var files = Directory.GetFiles("Scripts");

// Assert
Assert.Equal(expected, files);
}

[Fact]
public void ToolsFiles()
{
// Arrange
const string Path = "test_tools_output.txt";
var content = File.ReadAllLines(Path);

// Assert
Assert.Collection(
content,
c => Assert.Equal("jQuery", c));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="../../src/Microsoft.AspNetCore.SystemWebAdapters/build/Microsoft.AspnetCore.SystemWebAdapters.props" />

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>

<!-- Disable due to test -->
<EnableSystemWebAdapterNuGetWarnings>false</EnableSystemWebAdapterNuGetWarnings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac.Extras.Moq" Version="6.0.0" />
<PackageReference Include="AutoFixture" Version="4.15.0" />
<PackageReference Include="Moq" Version="4.16.1" />
</ItemGroup>

<!-- Used for tests but not directly -->
<ItemGroup>
<PackageReference Include="jQuery" Version="3.5.1" CopyContent="true" />
</ItemGroup>

<Target Name="CopyToolsFilesForTest" AfterTargets="AddNugetContentFiles">
<ItemGroup>
<_TestOutput Include="$(OutDir)test_tools_output.txt" />
</ItemGroup>

<WriteLinesToFile
File="@(_TestOutput)"
Lines="@(_ToolsPackage)"
Overwrite="true"
Encoding="Unicode"/>
</Target>

<Import Project="../../src/Microsoft.AspNetCore.SystemWebAdapters/build/Microsoft.AspnetCore.SystemWebAdapters.targets" />

</Project>