Skip to content

Commit

Permalink
✅ fix testing line-ends
Browse files Browse the repository at this point in the history
  • Loading branch information
rsking committed Oct 21, 2024
1 parent 94ef6e2 commit 61cb555
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
5 changes: 0 additions & 5 deletions src/Tests/.gitattributes

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="..\lorem-ipsum.*" Link="%(FileName)%(Extension)" />
<EmbeddedResource Include="..\*.lzma" Link="%(FileName)%(Extension)" />
</ItemGroup>

<ItemGroup>
<_TxtEmbeddedResource Include="..\*.txt" Link="%(FileName)%(Extension)" />
</ItemGroup>

<ItemGroup>
Expand All @@ -33,4 +37,60 @@
<ProjectReference Include="..\..\IO.Compression.Lzma\IO.Compression.Lzma.csproj" />
</ItemGroup>

<UsingTask TaskName="ChangeLineEndings" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<DestinationFolder ParameterType="Microsoft.Build.Framework.ITaskItem" Required="true" />
<Result ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Using Namespace="System.IO.Compression" />
<Code Type="Fragment" Language="cs">
<![CDATA[
if (Files.Length > 0)
{
Result = new TaskItem[Files.Length];
for (var i = 0; i < Files.Length; i++)
{
var item = Files[i];
var link = item.GetMetadata("Link");
var sourceItemSpec = item.ItemSpec;
var destinationItemSpec = Path.Combine(DestinationFolder.ItemSpec, Path.GetFileName(item.ItemSpec));
if (!File.Exists(destinationItemSpec))
{
File.WriteAllText(destinationItemSpec, File.ReadAllText(sourceItemSpec).Replace("\r\n", "\n"));
}
var destinationItem = new TaskItem(destinationItemSpec);
if (link != null)
{
destinationItem.SetMetadata("Link", link);
}
Result[i] = destinationItem;
}
}
]]>
</Code>
</Task>
</UsingTask>



<Target Name="_UpdateEmbeddedResources"
BeforeTargets="CheckForDuplicateItems">

<ChangeLineEndings Files="@(_TxtEmbeddedResource)" DestinationFolder="$(IntermediateOutputPath)">
<Output ItemName="TxtEmbeddedResource" TaskParameter="Result" />
</ChangeLineEndings>

<ItemGroup>
<EmbeddedResource Include="@(TxtEmbeddedResource)" />
</ItemGroup>

</Target>

</Project>
Binary file modified src/Tests/lorem-ipsum.lzma
Binary file not shown.
17 changes: 17 additions & 0 deletions src/testEnvironments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "1",
"environments": [
// See https://aka.ms/remotetesting for more details
// about how to configure remote environments.
{
"name": "WSL Ubuntu",
"type": "wsl",
"wslDistribution": "Ubuntu-24.04"
},
{
"name": "Docker dotnet/sdk",
"type": "docker",
"dockerImage": "mcr.microsoft.com/dotnet/sdk"
}
]
}

0 comments on commit 61cb555

Please sign in to comment.