Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<UsingTask TaskName="LuYao.ResourcePacker.MSBuild.ResourcePackerTask"
AssemblyFile="$(MSBuildThisFileDirectory)..\tasks\netstandard2.0\LuYao.ResourcePacker.MSBuild.dll" />

<Target Name="PackResources" BeforeTargets="CopyFilesToOutputDirectory" Condition="'$(ResourcePackerEnabled)' == 'true'">
<Target Name="PackResources" BeforeTargets="AssignTargetPaths" Condition="'$(ResourcePackerEnabled)' == 'true'">
<PropertyGroup>
<ResourcePackerOutputFileName Condition="'$(ResourcePackerOutputFileName)' == ''">$(AssemblyName).dat</ResourcePackerOutputFileName>
</PropertyGroup>
Expand All @@ -13,5 +13,13 @@
AssemblyName="$(AssemblyName)"
ResourcePattern="$(ResourcePackerPattern)"
OutputFileName="$(ResourcePackerOutputFileName)" />

<!-- Add .dat file to None so it gets copied to referencing projects -->
<ItemGroup>
<None Include="$(OutputPath)$(ResourcePackerOutputFileName)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>$(ResourcePackerOutputFileName)</Link>
</None>
</ItemGroup>
</Target>
</Project>
15 changes: 15 additions & 0 deletions examples/App1/App1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Lib3\Lib3.csproj" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions examples/App1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using Lib1;

var lib = new LibraryClass();
Console.WriteLine(lib.GetMessage());
18 changes: 6 additions & 12 deletions examples/ExampleProject/ExampleProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@
<!--
NOTE: This example uses project references to demonstrate the library from source.
For external projects consuming the NuGet package, the MSBuild targets are automatically
imported and you don't need the UsingTask and Target declarations below.
imported and you don't need the UsingTask and Target import below.
See the main README.md for instructions on using the NuGet package.
-->
<UsingTask TaskName="LuYao.ResourcePacker.MSBuild.ResourcePackerTask"
AssemblyFile="$(MSBuildThisFileDirectory)..\..\LuYao.ResourcePacker.MSBuild\bin\$(Configuration)\netstandard2.0\LuYao.ResourcePacker.MSBuild.dll" />
AssemblyFile="..\..\LuYao.ResourcePacker.MSBuild\bin\$(Configuration)\netstandard2.0\LuYao.ResourcePacker.MSBuild.dll" />

<Import Project="..\..\LuYao.ResourcePacker.MSBuild\build\LuYao.ResourcePacker.MSBuild.props" />
<Import Project="..\..\LuYao.ResourcePacker.MSBuild\build\LuYao.ResourcePacker.MSBuild.targets" />

<Target Name="PackResources" BeforeTargets="CopyFilesToOutputDirectory" Condition="'$(ResourcePackerEnabled)' == 'true'">
<ResourcePackerTask
ProjectDir="$(ProjectDir)"
OutputPath="$(OutputPath)"
AssemblyName="$(AssemblyName)"
ResourcePattern="$(ResourcePackerPattern)"
OutputFileName="$(ResourcePackerOutputFileName)" />
</Target>

</Project>
</Project>
28 changes: 28 additions & 0 deletions examples/Lib1/Lib1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ResourcePackerEnabled>true</ResourcePackerEnabled>
<ResourcePackerPattern>*.res.*</ResourcePackerPattern>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\LuYao.ResourcePacker\LuYao.ResourcePacker.csproj" />
<ProjectReference Include="..\..\LuYao.ResourcePacker.MSBuild\LuYao.ResourcePacker.MSBuild.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="Resources\**\*.res.*" CopyToOutputDirectory="Never" />
</ItemGroup>

<!-- For development with project references, manually import and override assembly path -->
<UsingTask TaskName="LuYao.ResourcePacker.MSBuild.ResourcePackerTask"
AssemblyFile="..\..\LuYao.ResourcePacker.MSBuild\bin\$(Configuration)\netstandard2.0\LuYao.ResourcePacker.MSBuild.dll" />

<Import Project="..\..\LuYao.ResourcePacker.MSBuild\build\LuYao.ResourcePacker.MSBuild.props" />
<Import Project="..\..\LuYao.ResourcePacker.MSBuild\build\LuYao.ResourcePacker.MSBuild.targets" />

</Project>
6 changes: 6 additions & 0 deletions examples/Lib1/LibraryClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Lib1;

public class LibraryClass
{
public string GetMessage() => "Hello from Lib1";
}
1 change: 1 addition & 0 deletions examples/Lib1/Resources/test.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test resource content for Lib1
28 changes: 28 additions & 0 deletions examples/Lib2/Lib2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ResourcePackerEnabled>true</ResourcePackerEnabled>
<ResourcePackerPattern>*.res.*</ResourcePackerPattern>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Lib1\Lib1.csproj" />
<ProjectReference Include="..\..\LuYao.ResourcePacker\LuYao.ResourcePacker.csproj" />
<ProjectReference Include="..\..\LuYao.ResourcePacker.MSBuild\LuYao.ResourcePacker.MSBuild.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="Resources\**\*.res.*" CopyToOutputDirectory="Never" />
</ItemGroup>

<UsingTask TaskName="LuYao.ResourcePacker.MSBuild.ResourcePackerTask"
AssemblyFile="..\..\LuYao.ResourcePacker.MSBuild\bin\$(Configuration)\netstandard2.0\LuYao.ResourcePacker.MSBuild.dll" />

<Import Project="..\..\LuYao.ResourcePacker.MSBuild\build\LuYao.ResourcePacker.MSBuild.props" />
<Import Project="..\..\LuYao.ResourcePacker.MSBuild\build\LuYao.ResourcePacker.MSBuild.targets" />

</Project>
6 changes: 6 additions & 0 deletions examples/Lib2/Library2Class.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Lib2;

public class Library2Class
{
public string GetMessage() => "Hello from Lib2";
}
1 change: 1 addition & 0 deletions examples/Lib2/Resources/test.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test resource content for Lib2
28 changes: 28 additions & 0 deletions examples/Lib3/Lib3.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ResourcePackerEnabled>true</ResourcePackerEnabled>
<ResourcePackerPattern>*.res.*</ResourcePackerPattern>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Lib2\Lib2.csproj" />
<ProjectReference Include="..\..\LuYao.ResourcePacker\LuYao.ResourcePacker.csproj" />
<ProjectReference Include="..\..\LuYao.ResourcePacker.MSBuild\LuYao.ResourcePacker.MSBuild.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="Resources\**\*.res.*" CopyToOutputDirectory="Never" />
</ItemGroup>

<UsingTask TaskName="LuYao.ResourcePacker.MSBuild.ResourcePackerTask"
AssemblyFile="..\..\LuYao.ResourcePacker.MSBuild\bin\$(Configuration)\netstandard2.0\LuYao.ResourcePacker.MSBuild.dll" />

<Import Project="..\..\LuYao.ResourcePacker.MSBuild\build\LuYao.ResourcePacker.MSBuild.props" />
<Import Project="..\..\LuYao.ResourcePacker.MSBuild\build\LuYao.ResourcePacker.MSBuild.targets" />

</Project>
6 changes: 6 additions & 0 deletions examples/Lib3/Library3Class.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Lib3;

public class Library3Class
{
public string GetMessage() => "Hello from Lib3";
}
1 change: 1 addition & 0 deletions examples/Lib3/Resources/test.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test resource content for Lib3