Skip to content

Referenced dll's get deleted #1164

Closed
Closed

Description

@B1337

Steps to Reproduce

  1. Create 2 projects, a droid project and a pcl project.
  2. Add references to the pcl project that are in the output folder.
  3. Set both projects to output in the same output folder.
  4. Build the pcl project and then build the droid project.
  5. Referenced dlls in the pcl project are deleted after building droid the second time.

Expected Behavior

Dlls should not be deleted even if they are in the same output folder.

Actual Behavior

Some dlls are deleted when building droid for the second time.

Version Information

Seem to be Xamarin.Droid 8.1.0.25
In earlier versions this wasnt a problem

Log File

Area: Building

Activity

  1. dellis1972 commented on Jan 10, 2018

    @dellis1972
    Contributor

    @B1337 can you provide diagnostic build output for step 4. I suspect that the IncrementalClean target from MSBuild is deleting the files. We might need to get someone from the MSbuild team to look at this issue.

  2. added
    need-info
    on Jan 10, 2018
  3. B1337 commented on Jan 12, 2018

    @B1337
    Author

    I updated VS and with Xamarin.Droid version 8.1.3 the issue is still there.
    Here is the output from a test project:
    Output Test App.txt

  4. dellis1972 commented on Jan 18, 2018

    @dellis1972
    Contributor

    @B1337 are you able to repo the same issue using a normal console application? I have a feeling this is expected behaviour. If you have binaries that you reference directly I would not put those in the output folder. I put those in a different folder called "References" they will be copied into the output as part of the build process.

  5. B1337 commented on Jan 19, 2018

    @B1337
    Author

    I wasn't able to reproduce this by building iOS or UWP so I don't think a console app will either but I will try it anyway.

  6. B1337 commented on Jan 19, 2018

    @B1337
    Author

    After many tries I was unable to reproduce the issue with a normal console app. Where the steps to reproduce are simple the issue should've occurred already.

  7. dellis1972 commented on Jan 22, 2018

    @dellis1972
    Contributor

    @B1337 I have been trying to repo this issue using the instructions provided and have been unable too on the latest stable release.
    Can you provide a test project which replicates the issue?

  8. B1337 commented on Jan 22, 2018

    @B1337
    Author

    Edit:
    Seemed to be missing some projects.

  9. dellis1972 commented on Jan 22, 2018

    @dellis1972
    Contributor

    @B1337 it seems to be misspend Core.csproj?

  10. B1337 commented on Jan 22, 2018

    @B1337
    Author

    Sorry, here is the complete project.
    Also included are droid and iOS.
    App1.zip

  11. dellis1972 commented on Jan 22, 2018

    @dellis1972
    Contributor

    Thanks, I can now repo the issue. As I suspected the MSBuild IncrementalClean is causing the problem. The Core.dll and a bunch of other files are removed which you can see in the CleanOrphanFilesDeleted ItemGroup. Now I can figure out how to work around this issue.

  12. added
    Area: App+Library Build
    and removed
    need-info
    on Jan 22, 2018
  13. added this to the d15-7 milestone on Jan 22, 2018
  14. 7 remaining items

  15. irreal commented on Feb 1, 2018

    @irreal

    @dellis1972 I have included the FixUp.targets and imported in my .csproj, but nothing has changed. IncrementalClean still deletes my .dll and then the build crashes when it can't load it.

    Can you share more details on how to implement the workaround?
    I tried importing it like this

    <Import Project="..\..\..\Shared\TemporaryAndroidFix.targets" />
    

    Double checked the relative path, it's fine, and there's other targets in that same folder that do get hit.

    Then i tried moving the .targets file to the same folder as my .csproj, and referecing just like you indicated, even keeping the same file name as you show
    <Import Project="FixUp.targets" />
    but still it keeps failing when building through VSTS

    Any ideas?

  16. dellis1972 commented on Feb 1, 2018

    @dellis1972
    Contributor
  17. modplug commented on Feb 1, 2018

    @modplug

    I also tried to apply the patch without success

  18. alexstrong29 commented on Feb 1, 2018

    @alexstrong29

    I have also tried the workaround but no luck. Although the error is now different but I can't really make sense of it.

    tfs-build-error

  19. quality-catalyst commented on Feb 2, 2018

    @quality-catalyst

    @jonpryor Would you please share details how to apply your mentioned workaround until 15.7 is released?

    To work around this problem we just need to tell the
    IncrementalClean target to ignore any dll in the $(OutDir). Since
    we already have a target in place to handle this we can just expand
    the list of files it should be ignoring.

  20. mr-kg commented on Feb 4, 2018

    @mr-kg

    Also in the same boat here. My CI/CD is halted at the moment .

  21. abosquet commented on Feb 6, 2018

    @abosquet

    This workaround doesn't work for me too.
    My referenced dlls are still deleted.

    I tried to implement it in the minimal repro project I posted initially in bugzilla:
    https://bugzilla.xamarin.com/show_bug.cgi?id=61108

    Seems the workaround is simply ignored according to the log:
    The target "_RegisterAndroidFilesWithFileWrites" listed in a BeforeTargets attribute at "c:\agent_work\5\s\BuildFails\BuildFails\BuildFails.Android\FixUp.targets (2,29)" does not exist in the project, and will be ignored.

    @dellis1972 : Would be great if you could implement your workaround in the repro project I uploaded in bugzilla and share with us the result.

  22. alexstrong29 commented on Feb 6, 2018

    @alexstrong29

    @dellis1972 FYI Applying your suggested fix of changing BeforeTargets="IncrementalClean" in the FixUp.targets file worked!

    capture

  23. modplug commented on Feb 9, 2018

    @modplug

    Thanks. Just got my build working again

  24. ghost locked as resolved and limited conversation to collaborators on Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: App+Library Build

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions