Skip to content

Commit 013401c

Browse files
committed
Fix CustomDesignerTargetSetupDependenciesForDesigner Test
1 parent b1cd252 commit 013401c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ public CustomTextView(Context context, IAttributeSet attributes) : base(context,
9090
using (var libb = CreateDllBuilder (Path.Combine (path, lib.ProjectName), false, false))
9191
using (var appb = CreateApkBuilder (Path.Combine (path, proj.ProjectName), false, false)) {
9292
// Save the library project, but don't build it yet
93-
libb.Save (lib);
93+
libb.Save (lib, saveProject: true);
94+
FileAssert.Exists (Path.Combine(Root, path, lib.ProjectName, lib.ProjectFilePath));
9495
appb.BuildLogFile = "build1.log";
9596
appb.Target = target;
96-
Assert.IsTrue (appb.DesignTimeBuild (proj), $"build should have succeeded for target `{target}`");
97+
Assert.IsTrue (appb.Build (proj, parameters: DesignerParameters), $"build should have succeeded for target `{target}`");
9798
Assert.IsTrue (appb.Output.AreTargetsAllBuilt ("_UpdateAndroidResgen"), "_UpdateAndroidResgen should have run completely.");
9899
Assert.IsTrue (appb.Output.AreTargetsAllBuilt ("_Foo"), "_Foo should have run completely");
99100
var customViewPath = Path.Combine (Root, appb.ProjectDirectory, proj.IntermediateOutputPath, "res", "layout", "custom_text.xml");
@@ -104,10 +105,10 @@ public CustomTextView(Context context, IAttributeSet attributes) : base(context,
104105
Assert.IsNotNull (doc.Element ("LinearLayout").Element ("unnamedproject.CustomTextView"),
105106
"unnamedproject.CustomTextView should have not been replaced with a $(Hash).CustomTextView");
106107
// Build the library project now
107-
Assert.IsTrue (libb.Build (lib, doNotCleanupOnUpdate: true), "library build should have succeeded.");
108+
Assert.IsTrue (libb.Build (lib, doNotCleanupOnUpdate: true, saveProject: true), "library build should have succeeded.");
108109
appb.Target = "Build";
109110
appb.BuildLogFile = "build2.log";
110-
Assert.IsTrue (appb.Build (proj, doNotCleanupOnUpdate: true, saveProject:false), "app build should have succeeded.");
111+
Assert.IsTrue (appb.Build (proj, doNotCleanupOnUpdate: true, saveProject: false), "app build should have succeeded.");
111112
Assert.IsTrue (appb.Output.AreTargetsAllBuilt ("_UpdateAndroidResgen"), "_UpdateAndroidResgen should have run completely.");
112113
Assert.IsTrue (appb.Output.AreTargetsAllBuilt ("_Foo"), "_Foo should have run completely");
113114
doc = XDocument.Load (customViewPath);
@@ -117,7 +118,16 @@ public CustomTextView(Context context, IAttributeSet attributes) : base(context,
117118
"unnamedproject.CustomTextView should have been replaced with a $(Hash).CustomTextView");
118119
appb.Target = target;
119120
appb.BuildLogFile = "build3.log";
120-
Assert.IsTrue (appb.DesignTimeBuild (proj, doNotCleanupOnUpdate: true), $"build should have succeeded for target `{target}`");
121+
Assert.IsTrue (appb.DesignTimeBuild (proj, parameters: DesignerParameters, doNotCleanupOnUpdate: true), $"build should have succeeded for target `{target}`");
122+
Assert.IsFalse (appb.Output.AreTargetsAllSkipped ("_UpdateAndroidResgen"), "_UpdateAndroidResgen should not have been skipped.");
123+
Assert.IsTrue (appb.Output.AreTargetsAllBuilt ("_Foo"), "_Foo should have run completely");
124+
doc = XDocument.Load (customViewPath);
125+
Assert.IsNull (doc.Element ("LinearLayout").Element ("UnnamedProject.CustomTextView"),
126+
"UnnamedProject.CustomTextView should have been replaced with a $(Hash).CustomTextView");
127+
Assert.IsNull (doc.Element ("LinearLayout").Element ("unnamedproject.CustomTextView"),
128+
"unnamedproject.CustomTextView should have been replaced with a $(Hash).CustomTextView");
129+
appb.BuildLogFile = "build4.log";
130+
Assert.IsTrue (appb.DesignTimeBuild (proj, parameters: DesignerParameters, doNotCleanupOnUpdate: true), $"build should have succeeded for target `{target}`");
121131
Assert.IsTrue (appb.Output.AreTargetsAllSkipped ("_UpdateAndroidResgen"), "_UpdateAndroidResgen should have been skipped.");
122132
Assert.IsTrue (appb.Output.AreTargetsAllBuilt ("_Foo"), "_Foo should have run completely");
123133
doc = XDocument.Load (customViewPath);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This file is used by all project types, including binding projects.
4747
<_AndroidLibraryProjectImportsCache Condition=" '$(DesignTimeBuild)' == 'true' And !Exists ('$(_AndroidLibraryProjectImportsCache)') ">$(_AndroidLibraryProjectImportsDesignTimeCache)</_AndroidLibraryProjectImportsCache>
4848
<_AndroidBuildPropertiesCache Condition=" '$(DesignTimeBuild)' == 'true' ">$(_AndroidDesignTimeBuildPropertiesCache)</_AndroidBuildPropertiesCache>
4949
<_GeneratorStampFile Condition=" '$(DesignTimeBuild)' == 'true' ">$(_AndroidIntermediateDesignTimeStampDirectory)generator.stamp</_GeneratorStampFile>
50+
<_AndroidResgenFlagFile Condition=" '$(DesignTimeBuild)' == 'true' ">$(_AndroidIntermediateDesignTimeBuildDirectory)R.cs.flag</_AndroidResgenFlagFile>
5051
</PropertyGroup>
5152
<MakeDir
5253
Condition=" '$(_AndroidIsBindingProject)' != 'true' And !Exists ('$(_AndroidIntermediateDesignTimeBuildDirectory)') "

0 commit comments

Comments
 (0)