Skip to content

Correct $(IntermediateDepsFilePath) logic#11527

Closed
dougbu wants to merge 2 commits into
masterfrom
dougbu/IntermediateDepsFilePath
Closed

Correct $(IntermediateDepsFilePath) logic#11527
dougbu wants to merge 2 commits into
masterfrom
dougbu/IntermediateDepsFilePath

Conversation

@dougbu
Copy link
Copy Markdown

@dougbu dougbu commented May 1, 2020

  • restore previous behaviour of this target in the non-single-file case
    • ensure $(PublishDepsFilePath) exists after GeneratePublishDependencyFile target runs

- restore previous behaviour of this target in the non-single-file case
  - ensure `$(PublishDepsFilePath)` exists after `GeneratePublishDependencyFile` target runs
<PublishDepsFilePath Condition=" '$(PublishDepsFilePath)' == '' And '$(PublishSingleFile)' != 'true'">$(PublishDir)$(ProjectDepsFileName)</PublishDepsFilePath>
<IntermediateDepsFilePath Condition=" '$(PublishDepsFilePath)' == '' And '$(PublishSingleFile)' != 'true'">$(PublishDir)$(ProjectDepsFileName)</IntermediateDepsFilePath>
<IntermediateDepsFilePath Condition=" '$(IntermediateDepsFilePath)' == ''">$(IntermediateOutputPath)$(ProjectDepsFileName)</IntermediateDepsFilePath >
<PublishDepsFilePath Condition=" '$(PublishDepsFilePath)' == '' And '$(PublishSingleFile)' != 'true'">$(IntermediateDepsFilePath)</PublishDepsFilePath>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the deps.json file is directly written to the publish directory, it should be removed from ResolvedFileToPublish here in the non-single-file case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, I'm not sure its a good idea to write to the publish directory -- before CopyFilesToPublishDirectory has run -- because something may be introduced into ResolvedFileToPublish that overwrites this file. Isn't it?

CC: @dsplaisted

Copy link
Copy Markdown
Contributor

@swaroop-sridhar swaroop-sridhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dougbu, in this case, I think it is better for InjectRequestHandlerOnPublish to run after CopyFilesToPublishDirectory which will copy the deps file from IntermediateDepsFilePath to PublishDepsFilePath.

If this cannot change due to legacy reasons, then please apply the change I've suggested here.

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

If this cannot change due to legacy reasons

Won't external developers get tripped up by this breaking change too? For the non-single-file case, running after GeneratePublishDependencyFile and using $(PublishDepsFilePath) worked perfectly. But, I defer to you and @dsplaisted. Thoughts?

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

Oops, whoever I accidentally tagged instead of @dsplaisted, my apologies.

- not needed when value is the same as `$(PublishDepsFilePath)`
@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

Hmm, what's up w/ the pipeline failure? Did a credential just expire?

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

/azp run dotnet-sdk-public-ci

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

Oh good, credential problem went away.

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

🆙📅 to take @swaroop-sridhar's suggestion in case we decide to fix the latest break. Otherwise I'll use $(IntermediateDepsFilePath) in dotnet/aspnetcore#21017. It doesn't feel right to leave an incorrect .deps file in the obj/ directory and that would happen if I moved our fixup after the CopyFilesToPublishDirectory target. (Must say it also doesn't feel right to leave a .deps file in the obj/ directory at all in the non-single-file case.)

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

@swaroop-sridhar should I merge this change after PR validation completes or wait for word from @dsplaisted on his preferences?

@dsplaisted
Copy link
Copy Markdown
Member

So we're now hitting a different break than we fixed in #11462, right?

The ASP.NET targets:

  • Run after GenerateBuildDependencyFile and GeneratePublishDependencyFile
  • Expect PublishDepsFilePath to be the path to a deps file that they can rewrite

I think that means to minimize breakage, we would have to:

  • Have PublishDepsFilePath point to the path in the output folder
  • Not use ResolvedFileToPublish to copy to the output folder, because then targets such as ASP.NET may run before it's copied there

It's not feasible for us to make that true for single-file apps, so existing targets could still get broken in that case.

Is that all correct? Is that what these changes are trying to achieve?

Is it possible to update the ASP.NET targets to work with the current logic?

@@ -987,10 +987,11 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup>
<!-- IntermediateDepsFilePath is the location where the deps.json file is originally created
PublishDepsFilePath is the location where the deps.json resides when published
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please update the comments here to say:
In the single-file case, we write deps file to intermediate dir, and it is bundled into the single-file app.
In the non-single-file case, we write deps file directly in the publish directory due to legacy reasons.

@swaroop-sridhar
Copy link
Copy Markdown
Contributor

So we're now hitting a different break than we fixed in #11462, right?

The ASP.NET targets:

  • Run after GenerateBuildDependencyFile and GeneratePublishDependencyFile
  • Expect PublishDepsFilePath to be the path to a deps file that they can rewrite

I think that means to minimize breakage, we would have to:

  • Have PublishDepsFilePath point to the path in the output folder
  • Not use ResolvedFileToPublish to copy to the output folder, because then targets such as ASP.NET may run before it's copied there

It's not feasible for us to make that true for single-file apps, so existing targets could still get broken in that case.

Is that all correct? Is that what these changes are trying to achieve?

Is it possible to update the ASP.NET targets to work with the current logic?

Yes this is accurate.

As @dougbu has mentioned, it is possible to fix asp.net targets by using IntermediateDepsFilePath instead of PublishDepsFilePath.
Or, by using PublishDepsFilePath after CopyResolvedFilesToPublishDirectory has run.

This change is trying to preserve legacy behavior for asp.net and other customers who may use these targets/properties not publishing for non-single-file.

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

Can you please update the comments here to say…

I'll do this if we decide to take this fix. It sounds like @dsplaisted is unconvinced😸

@dsplaisted
Copy link
Copy Markdown
Member

I'm unconvinced in the sense that I'm not really sure what we should do.

I think @marcpopMSFT and/or @KathleenDollard were looking at having a process where we at least document breaking changes like this.

So, I think we should fix ASP.NET to work with the current logic to unblock ourselves, and have a discussion about what we should do with this break.

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

🆗 I'll leave this open rather than fixing the comment or the busted tests (PublishDepsFilePathIsSetAsExpectedForNormalApps and It_cleans_before_trimmed_single_file_publish) immediately. We can use this if we decide to make a change and close it otherwise.

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

Shoot. I wasn't thinking things through. Using $(IntermediateDepsFilePath) won't work because we also want the path to help us find the native DLL to copy. I'll have to switch to running our target after CopyResolvedFilesToPublishDirectory even though I'd rather not leave an incorrect (and, to me, useless) .deps file in the obj/ folder.

@swaroop-sridhar
Copy link
Copy Markdown
Contributor

Shoot. I wasn't thinking things through. Using $(IntermediateDepsFilePath) won't work because we also want the path to help us find the native DLL to copy. I'll have to switch to running our target after CopyResolvedFilesToPublishDirectory even though I'd rather not leave an incorrect (and, to me, useless) .deps file in the obj/ folder.

I think leaving behind an "incorrect" .deps file in obj folderis not a major concern. It is actually typical of post-processing tools to modify outputs between obj and bin directories. For example, R2R takes files in obj directory, modifies them (elsewhere) and copies the modified output to bin directory. So, the bin and obj directories will not always match.

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 1, 2020

I think leaving behind an "incorrect" .deps file in obj folderis not a major concern.

I understand that reasoning though the breaking change part of it and the utility of the new obj/ file still feels Just Wrong:tm: 😉

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 2, 2020

/fyi the CopyResolvedFilesToPublishDirectory target doesn't exist and is a typo in a few comments above. Believe CopyFilesToPublishDirectory is correct.

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 11, 2020

@dsplaisted @swaroop-sridhar @marcpopMSFT @KathleenDollard have you had a chance to discuss whether to revert this breaking change or documented it?

@dougbu
Copy link
Copy Markdown
Author

dougbu commented May 30, 2020

/ping ❔

@swaroop-sridhar
Copy link
Copy Markdown
Contributor

I recommend that we close this PR, and document the change in PublishDepsFilePath semantics.

@dougbu
Copy link
Copy Markdown
Author

dougbu commented Jun 1, 2020

@swaroop-sridhar nobody goes looking in the regular docs for notifications of breaking changes. Suggest you need an announcement too.

@dougbu dougbu closed this Jun 1, 2020
@dougbu dougbu deleted the dougbu/IntermediateDepsFilePath branch June 1, 2020 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants