Skip to content

Commit b2953d6

Browse files
dellis1972jonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks] Move DesignTime Cache files to designtime folder. (#986)
Fixes: https://devdiv.visualstudio.com/DevDiv/XamarinVS/_queries?id=512752%2F&triage=true&_a=edit The DesignTime build is generally run before any nuget packages have been restored. As a result we end up with empty cache files. Because those files exist and are considered uptodate, when the main build finally happens they are not re-generated. This causes errors like error: Error: No resource found that matches the given name: attr 'colorAccent'. on a new default template. The DesignTime build should have its own set of cache files which do not conflict with the main build. This way when the main build runs the cache files will not be in place.
1 parent 8b654ad commit b2953d6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1767,19 +1767,27 @@ public void BuildBasicApplicationCheckPdb ()
17671767
[Test]
17681768
public void BuildInDesignTimeMode ([Values(false, true)] bool useManagedParser)
17691769
{
1770+
var path = Path.Combine ("temp", TestContext.CurrentContext.Test.Name);
17701771
var proj = new XamarinAndroidApplicationProject () {
17711772
IsRelease = true,
17721773
};
17731774
proj.SetProperty ("AndroidUseManagedDesignTimeResourceGenerator", useManagedParser.ToString ());
1774-
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name), false ,false)) {
1775+
using (var builder = CreateApkBuilder (path, false ,false)) {
17751776
builder.Verbosity = LoggerVerbosity.Diagnostic;
17761777
builder.Target = "UpdateAndroidResources";
17771778
builder.Build (proj, parameters: new string[] { "DesignTimeBuild=true" });
17781779
Assert.IsFalse (builder.Output.IsTargetSkipped ("_CreatePropertiesCache"), "target \"_CreatePropertiesCache\" should have been run.");
17791780
Assert.IsFalse (builder.Output.IsTargetSkipped ("_ResolveLibraryProjectImports"), "target \"_ResolveLibraryProjectImports\' should have been run.");
1781+
var librarycache = Path.Combine (Root, path, proj.IntermediateOutputPath, "designtime", "libraryprojectimports.cache");
1782+
Assert.IsTrue (File.Exists (librarycache), $"'{librarycache}' should exist.");
1783+
librarycache = Path.Combine (Root, path, proj.IntermediateOutputPath, "libraryprojectimports.cache");
1784+
Assert.IsFalse (File.Exists (librarycache), $"'{librarycache}' should not exist.");
17801785
builder.Build (proj, parameters: new string[] { "DesignTimeBuild=true" });
17811786
Assert.IsFalse (builder.Output.IsTargetSkipped ("_CreatePropertiesCache"), "target \"_CreatePropertiesCache\" should have been run.");
17821787
Assert.IsTrue (builder.Output.IsTargetSkipped ("_ResolveLibraryProjectImports"), "target \"_ResolveLibraryProjectImports\' should have been skipped.");
1788+
Assert.IsTrue (builder.Clean (proj), "Clean Should have succeeded");
1789+
librarycache = Path.Combine (Root, path, proj.IntermediateOutputPath, "designtime", "libraryprojectimports.cache");
1790+
Assert.IsFalse (File.Exists (librarycache), $"'{librarycache}' should exist.");
17831791
}
17841792
}
17851793

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,11 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
385385
<DesignTimeBuild Condition=" '$(DesignTimeBuild)' == '' ">true</DesignTimeBuild>
386386
<ManagedDesignTimeBuild Condition=" '$(AndroidUseManagedDesignTimeResourceGenerator)' == 'True' And '$(DesignTimeBuild)' == 'True' And '$(BuildingInsideVisualStudio)' == 'True' ">True</ManagedDesignTimeBuild>
387387
<ManagedDesignTimeBuild Condition=" '$(ManagedDesignTimeBuild)' == '' ">False</ManagedDesignTimeBuild>
388+
<_AndroidResourcePathsCache Condition=" '$(DesignTimeBuild)' == 'true' ">$(_AndroidDesignTimeResDirIntermediate)resourcepaths.cache</_AndroidResourcePathsCache>
389+
<_AndroidLibraryImportsCache Condition=" '$(DesignTimeBuild)' == 'true' ">$(_AndroidDesignTimeResDirIntermediate)libraryimports.cache</_AndroidLibraryImportsCache>
390+
<_AndroidLibraryProjectImportsCache Condition=" '$(DesignTimeBuild)' == 'true' ">$(_AndroidDesignTimeResDirIntermediate)libraryprojectimports.cache</_AndroidLibraryProjectImportsCache>
388391
</PropertyGroup>
392+
<MakeDir Directories="$(_AndroidDesignTimeResDirIntermediate)" Condition=" '$(DesignTimeBuild)' == 'true' " />
389393
</Target>
390394

391395
<PropertyGroup>

0 commit comments

Comments
 (0)