Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to overwrite the source assembly in XBD #128

Merged
merged 5 commits into from Mar 21, 2017

Conversation

bholmes
Copy link
Contributor

@bholmes bholmes commented Mar 13, 2017

With Android builds we are seeing a number of issues

  • Warnings that assemblies referenced from the NuGet can not be found
    (Not errors from what I can tell.)
  • Build time errors on first build because resources can not be found
    (Clean builds appear to fix this too, but yuck)
  • Slow VS experience when IDE is at idle. We believe this is because of
    design time builds that are running. Changing the reference list after
    references are resolved causes more processes to spawn.

This patch avoids changing the reference list after the resolve assembly step runs.
Instead the source assembly is updated and written back to the same location and not
the intermediate directory. It appears to work in the cases I tested but we need to
run a full set and have the community tell us how it is working.

There is now a property on all of the resource restore tasks that allow the behavior to be configured.
On Android we default to overwrite and on iOS we continue to use the intermediate folder by default.

We need to add an optimization to know if we need to open the assembly in cecil. Right now we always
open the file. It is taking a second in my tests. We could write out and check for a 'marker' file.

This will buy us some more time as a temporary workaround. We are working on changes
needed in Xamarin Android so that we can add aar files to the project build list and not
require that we re-embed the aar or reference files.

With Android builds we are seeing a number of issues

 - Warnings that assemblies referenced from the NuGet can not be found
   (Not errors from what I can tell.)
 - Build time errors on first build because resources can not be found
   (Clean builds appear to fix this too, but yuck)
 - Slow VS experience when IDE is at idle.  We believe this is because of
   design time builds that are running.  Changing the reference list after
   references are resolved causes more processes to spawn.

 This patch avoids changing the reference list after the resolve assembly step runs.
 Instead the source assembly is updated and written back to the same location and not
 the intermediate directory.  It appears to work in the cases I tested but we need to
 run a full set and have the community tell us how it is working.

 There is now a property on all of the resource restore tasks that allow the behavior to be configured.
 On Android we default to overwrite and on iOS we continue to use the intermediate folder by default.

 We need to add an optimization to know if we need to open the assembly in cecil.  Right now we always
 open the file.  It is taking a second in my tests.  We could write out and check for a 'marker' file.

 This will buy us some more time as a temporary workaround.  We are working on changes
 needed in Xamarin Android so that we can add aar files to the project build list and not
 require that we re-embed the aar or reference files.
Adding checks to not write out the dll when adding resources if
the source dll is the same as the target dll location and the resources
are already packed.
@bholmes
Copy link
Contributor Author

bholmes commented Mar 16, 2017

Keep an eye on the following when reviewing this PR.

bug 52967
Forums Post

@@ -104,9 +104,11 @@ public override bool Execute ()
bool MergeResources (IAssemblyResolver resolver, string originalAsmPath, string mergedAsmPath, string assemblyName, List<ITaskItem> resourceItems)
{
var disposeList = new List<IDisposable> ();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crying out for some CompositeDisposable goodness :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice suggestion! I would like to use that however I just found that it requires that I ship additional dlls in the NuGet just for a simple concept.

Redth and others added 3 commits March 21, 2017 11:01
When merging resources into a .dll, we want to write out a marker file (`TheFile.dll.stamp` in this case) to indicate the .dll file has already been processed and we don’t need to inspect it (open it) to check to see if it needs processing.  This should save some time in the process.

I’ve also added more FileWrites outputs for the task (we’ll add the `obj/[Config]/XbdMerge` folder as well as any `.stamp` marker files we create here so that when a build is cleaned, everything is removed.

Finally, fixed typo in OverwriteSourceAssembly property.
@mattleibow mattleibow merged commit 864ec49 into xamarin:master Mar 21, 2017
@bholmes bholmes deleted the XBD-OverwiteSourceAssembly branch March 22, 2017 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants