Skip to content

Conversation

@jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Aug 28, 2019

When doing some testing in the IDE, I noticed something odd for an
incremental deploy:

Building target "_BuildApkFastDev" completely.
Input file "obj\Debug\90\adb.props" is newer than output file "obj\Debug\90\android\bin\com.companyname.app14.apk".

This target took 2.470s in this case.

This was the Android App template in VS 2019 (not Xamarin.Forms).

I just modified a .cs file, how did adb.props change???

It turns out during Build, $(AdbTarget) is blank and during Install
it is properly set. That means that Install is currently always
running _BuildApkFastDev on incremental deployments.

I let the IDE team know, so they can see about sending $(AdbTarget)
during Build. However, they can't do this in every case, due to the
way the UI is setup. Depending on the user's selection, current
document, focus, etc. the play button in VS may not be enabled or even
know the current attached device.

This leads me to think we should really change something in our
MSBuild targets, which currently does:

<WriteLinesToFile
    Condition=" '$(DesignTimeBuild)' != 'True' "
    File="$(_AdbPropertiesCache)"
    Lines="AdbTarget=$(AdbTarget);AdbOptions=$(AdbOptions)"
    Overwrite="true"
    WriteOnlyWhenDifferent="true"
/>

If we didn't write this file when $(AdbTarget) is blank, the problem
would be avoided. However, we also should write the file if it does
not exist. If an Input to a target doesn't exist, it will run every
time. adb.props is used as Inputs for some targets.

I added a test for this scenario in the MSBuildDeviceIntegration
tests.

When doing some testing in the IDE, I noticed something odd for an
incremental deploy:

    Building target "_BuildApkFastDev" completely.
    Input file "obj\Debug\90\adb.props" is newer than output file "obj\Debug\90\android\bin\com.companyname.app14.apk".

This target took 2.470s in this case.

This was the Android App template in VS 2019 (not Xamarin.Forms).

I just modified a `.cs` file, how did `adb.props` change???

It turns out during `Build`, `adb.props` is blank and during `Install`
it is properly set. That means that `Install` is currently always
running `_BuildApkFastDev` on incremental deployments.

I let the IDE team know, so they can see about sending `$(AdbTarget)`
during `Build`. However, they can't do this in every case, due to the
way the UI is setup. Depending on the user's selection, current
document, focus, etc. the play button in VS may not be enabled or even
*know* the current attached device.

This leads me to think we should really change something in our
MSBuild targets, which currently does:

    <WriteLinesToFile
        Condition=" '$(DesignTimeBuild)' != 'True' "
        File="$(_AdbPropertiesCache)"
        Lines="AdbTarget=$(AdbTarget);AdbOptions=$(AdbOptions)"
        Overwrite="true"
        WriteOnlyWhenDifferent="true"
    />

If we didn't write this file when `$(AdbTarget)` is blank, the problem
would be avoided. However, we also should write the file if it does
not exist. If an `Input` to a target doesn't exist, it will run every
time. `adb.props` is used as `Inputs` for some targets.

I added a test for this scenario in the `MSBuildDeviceIntegration`
tests.
@jonpryor jonpryor merged commit e61a4ea into dotnet:master Aug 28, 2019
@jonathanpeppers jonathanpeppers deleted the blank-adbtarget branch August 28, 2019 21:12
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants