Skip to content

Commit

Permalink
fix: Alter Android ResourcesGenerationTask to use `LibraryResourceDir…
Browse files Browse the repository at this point in the history
…ectories`

Context unoplatform#10686
  • Loading branch information
dellis1972 committed Nov 7, 2023
1 parent 94623b0 commit f397d80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/SourceGenerators/Uno.UI.Tasks/Content/Uno.UI.Tasks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,15 @@
<Output TaskParameter="AssignedFiles" ItemName="PRIResourceWithTargetPath" />
</AssignTargetPath>

<PropertyGroup>
<_ResourceOutputPath>$(IntermediateOutputPath)g\ResourcesGenerator</_ResourceOutputPath>
<_ResourceStampFile>$(IntermediateOutputPath)g\uno.stamp</_ResourceStampFile>
</PropertyGroup>

<ResourcesGenerationTask_v0 Resources="@(PRIResourceWithTargetPath)"
TargetProjectDirectory="$(ProjectDir)"
TargetPlatform="$(XamarinProjectType)"
IntermediateOutputPath="$(IntermediateOutputPath)"
OutputPath="$(_ResourceOutputPath)"
DefaultLanguage="$(DefaultLanguage)"
IsUnoHead="$(_IsUnoHead)"
ProjectName="$(AssemblyName)"
Expand All @@ -94,7 +99,10 @@
</ResourcesGenerationTask_v0>
<ItemGroup>
<BundleResource Condition="'%(GeneratedFiles.UnoResourceTarget)' =='iOS'" Include="@(GeneratedFiles)" />
<AndroidResource Condition="'%(GeneratedFiles.UnoResourceTarget)' =='Android'" Include="@(GeneratedFiles)" />
<_UnoAndroidResources Condition="'%(GeneratedFiles.UnoResourceTarget)' =='Android'" Include="@(GeneratedFiles)" />
<LibraryResourceDirectories Condition="'@(_UnoAndroidResources->Count ())' != '0' " Include="$(_ResourceOutputPath)\r">
<StampFile>$(_ResourceStampFile)</StampFile>
</LibraryResourceDirectories>
<EmbeddedResource Condition="'%(GeneratedFiles.UnoResourceTarget)' =='Uno'" Include="@(GeneratedFiles)" />

<!-- Clear temporary group -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ public class ResourcesGenerationTask_v0 : Task
public string TargetProjectDirectory { get; set; }

[Required]
public string IntermediateOutputPath { get; set; }
public string OutputPath { get; set; }

[Required]
public string DefaultLanguage { get; set; }

[Output]
public ITaskItem[] GeneratedFiles { get; set; }

private string OutputPath => Path.Combine(TargetProjectDirectory, IntermediateOutputPath, "g", "ResourcesGenerator");

public override bool Execute()
{
Log.LogMessage($"Generating resources for platform : {TargetPlatform}");
Expand Down Expand Up @@ -227,7 +225,7 @@ private ITaskItem GenerateAndroidResources(string language, DateTime sourceLastW

// The file name have to be unique, otherwise it could be overwritten by a file with the same named defined directly in the application's head
var resourceMapName = Path.GetFileNameWithoutExtension(resource.ItemSpec)?.ToLowerInvariant();
var logicalTargetPath = Path.Combine(localizedDirectory, $"{resourceMapName}_resw-strings.xml");
var logicalTargetPath = Path.Combine("r", localizedDirectory, $"{resourceMapName}_resw-strings.xml");
var actualTargetPath = Path.Combine(OutputPath, logicalTargetPath);

var targetLastWriteTime = new FileInfo(actualTargetPath).LastWriteTimeUtc;
Expand Down

0 comments on commit f397d80

Please sign in to comment.