Skip to content

[Xamarin.Android.Build.Tasks] CopyResource should fail with an error code - #2237

Merged
dellis1972 merged 1 commit into
dotnet:masterfrom
jonathanpeppers:copyresource
Sep 28, 2018
Merged

[Xamarin.Android.Build.Tasks] CopyResource should fail with an error code#2237
dellis1972 merged 1 commit into
dotnet:masterfrom
jonathanpeppers:copyresource

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Context: #609

In a recent change, we removed StubApplication.java, but downstream
in monodroid we had MSBuild tasks that still expected the file to
exist.

We got an error such as:

Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: The "CopyResource" task failed unexpectedly.
Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object
Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: at Xamarin.Android.Tasks.CopyResource.Run (System.Reflection.Assembly assm, System.String ResourceName, System.String OutputPath, Microsoft.Build.Utilities.TaskLoggingHelper Log) [0x00058] in <5782345e71104ee895a29d54bde93c43>:0
Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: at Xamarin.Android.Tasks.CopyResource.Execute () [0x00018] in <5782345e71104ee895a29d54bde93c43>:0
Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in <528faf194f4946628868b84241d6ad15>:0
Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteInstantiatedTask>d__26.MoveNext () [0x001f6] in <528faf194f4946628868b84241d6ad15>:0

The CopyResource MSBuild task should fail more gracefully: log a
coded error, and mention the file name that was missing.

In addition to this change:

  • Added CopyResourceTests to verify resources that should be
    working, and the error code if it fails. We should add to the list
    if there are other files we want to verify are working. This test is
    very fast (<1s for entire class), because it doesn't need to build
    an entire project.
  • Documented the XA0116 error code.

…code

Context: dotnet#609

In a recent change, we removed `StubApplication.java`, but downstream
in `monodroid` we had MSBuild tasks that still expected the file to
exist.

We got an error such as:

    Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: The "CopyResource" task failed unexpectedly.
    Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object
    Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: at Xamarin.Android.Tasks.CopyResource.Run (System.Reflection.Assembly assm, System.String ResourceName, System.String OutputPath, Microsoft.Build.Utilities.TaskLoggingHelper Log) [0x00058] in <5782345e71104ee895a29d54bde93c43>:0
    Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: at Xamarin.Android.Tasks.CopyResource.Execute () [0x00018] in <5782345e71104ee895a29d54bde93c43>:0
    Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in <528faf194f4946628868b84241d6ad15>:0
    Xamarin.Android.Common.Debugging.targets(319,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteInstantiatedTask>d__26.MoveNext () [0x001f6] in <528faf194f4946628868b84241d6ad15>:0

The `CopyResource` MSBuild task should fail more gracefully: log a
coded error, and mention the file name that was missing.

In addition to this change:
- Added `CopyResourceTests` to verify resources that should be
  working, and the error code if it fails. We should add to the list
  if there are other files we want to verify are working. This test is
  very fast (<1s for entire class), because it doesn't need to build
  an entire project.
- Documented the `XA0116` error code.
@dellis1972

Copy link
Copy Markdown
Contributor

Test Failure if BCL and unrelated. Merging

@dellis1972
dellis1972 merged commit ab3bb8f into dotnet:master Sep 28, 2018
@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