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

[Xamarin.Android.Build.Tasks] target to simplify @(FileWrites) #2344

Merged
merged 1 commit into from
Oct 29, 2018

Conversation

jonathanpeppers
Copy link
Member

In our "MSBuild Best Practices" guide, the convention for using a
"stamp" file has a bit of boilerplate...

<Target Name="_MyTarget"
    Inputs="..."
    Outputs="$(_AndroidStampDirectory)_MyTarget.stamp">
  <!--...-->
  <Touch Files="$(_AndroidStampDirectory)_MyTarget.stamp" AlwaysCreate="True" />
  <ItemGroup>
    <FileWrites Include="$(_AndroidStampDirectory)_MyTarget.stamp" />
  </ItemGroup>
</Target>

It would be reasonably easy to mess this up.

If we add a new _AddFilesToFileWrites target that automatically adds
$(_AndroidStampDirectory)*.stamp to FileWrites, we can simplify
things:

<Target Name="_MyTarget"
    Inputs="..."
    Outputs="$(_AndroidStampDirectory)_MyTarget.stamp">
  <!--...-->
  <Touch Files="$(_AndroidStampDirectory)_MyTarget.stamp" AlwaysCreate="True" />
</Target>

This should be less prone to mistakes.

In our "MSBuild Best Practices" guide, the convention for using a
"stamp" file has a bit of boilerplate...

    <Target Name="_MyTarget"
        Inputs="..."
        Outputs="$(_AndroidStampDirectory)_MyTarget.stamp">
      <!--...-->
      <Touch Files="$(_AndroidStampDirectory)_MyTarget.stamp" AlwaysCreate="True" />
      <ItemGroup>
        <FileWrites Include="$(_AndroidStampDirectory)_MyTarget.stamp" />
      </ItemGroup>
    </Target>

It would be reasonably easy to mess this up.

If we add a new `_AddFilesToFileWrites` target that automatically adds
`$(_AndroidStampDirectory)*.stamp` to `FileWrites`, we can simplify
things:

    <Target Name="_MyTarget"
        Inputs="..."
        Outputs="$(_AndroidStampDirectory)_MyTarget.stamp">
      <!--...-->
      <Touch Files="$(_AndroidStampDirectory)_MyTarget.stamp" AlwaysCreate="True" />
    </Target>

This should be less prone to mistakes.
@jonathanpeppers
Copy link
Member Author

I think all the failures here are on-device network tests.

@jonpryor jonpryor merged commit 3dc914d into dotnet:master Oct 29, 2018
@jonathanpeppers jonathanpeppers deleted the filewrites-convention branch October 29, 2018 17:04
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 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.

2 participants