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
Add option to overwrite the source assembly in XBD #128
Conversation
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.
Keep an eye on the following when reviewing this PR. |
@@ -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> (); |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
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.
With Android builds we are seeing a number of issues
(Not errors from what I can tell.)
(Clean builds appear to fix this too, but yuck)
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.