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

Race condition in ExtensionsMetadataGenerator.targets leads to incorrect TargetDir #4057

Closed
TomBonnerAtTFL opened this issue Feb 6, 2019 · 3 comments

Comments

@TomBonnerAtTFL
Copy link

Investigative information

  • Timestamp: As of 05 Feb 2019
  • Function App version (1.0 or 2.0): 2.0
  • Function App name: N/A
  • Function name(s) (as appropriate): N/A
  • Invocation ID: N/A
  • Region: N/A

Repro steps

Referencing Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator should create an extensions.json file within our TargetDir. Currently, referencing both this, and Microsoft.Net.SDK.Functions leads to the incorrect TargetDir being used in the Generation part of this project.

Expected behavior

The file extensions.json should be generated in the correct TargetDir directory, with the correct values.

Actual behavior

A variety of things happen depending on the specific order of events, but most resolve into an empty extensions.json file being outputted somewhere.

Known workarounds

Putting a custom .targets file within your project.

Related information

I'm fairly sure this is the cause of a lot of issues given I believe (of course I could be wrong) this bug is referenced in the following:

I have a pull-request which I'll attach shortly.

The issue is mostly caused by https://github.com/Azure/azure-functions-vs-build-sdk/blob/master/src/Microsoft.NET.Sdk.Functions.MSBuild/Targets/netstandard1.0/Microsoft.NET.Sdk.Functions.Build.targets#150 changing the TargetPath which (given the Property's in the current Extension.Targets are set at start) means that the ConsoleApp within ExtensionsMetadataGenerator executes over the wrong directory.

PS, my apologies for re-creating this, the original was under my personal GitHub account @moritonal

@TomBonnerAtTFL
Copy link
Author

TomBonnerAtTFL commented Feb 22, 2019

Okay, after a discussion on PR #4059 about the issue I'm at the point where I believe a fix is roughly the following:

  • Update microsoft.net.sdk.functions\**\build\netstandard1.0ExtensionsMetadataGeneratorVersion.props and microsoft.net.sdk.functions\**\microsoft.net.sdk.functions.nuspec to version 1.0.2 (and try not to ask why it's hard-coded in a props file).
  • Remove any hard-reference to Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator in your code (because otherwise this'll take priority and initiate too fast).

That's producing a solid extensions.json file on my machine and requires no consumer changes (although does require them to NOT reference metadata, which many people do under the belief it solved prior issues).

An update to ExtensionsMetadataGenerator to lazy evaluate the properties could fix some issues where it's directly referenced, but there are knock-on effects given ExtensionsMetadataGenerator has an odd _ResolveAdditionalReferenceCopyLocalPathsForFunctionsExtensions target that requires early evaluation. Albeit I havn't seen any use of it so far.

Share and Enjoy
Tom

@brettsam
Copy link
Member

I've just released 1.0.25 to nuget: https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/1.0.25 which now updates everything to use ExtensionsMetadataGenerator 1.0.2 so this should now work. Please give that a try -- I'm pretty sure this addresses the issue here so I'm closing this issue.

However, the underlying "hardcoded version" issue isn't fixed. I've created Azure/azure-functions-vs-build-sdk#277 to track the fixing of this.

@brettsam
Copy link
Member

And thank you @TomBonnerAtTFL for working through this with me! If you think this doesn't address everything, feel free to re-open this.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants