Skip to content

Fix PublishDepsFilePath setting#11462

Merged
swaroop-sridhar merged 3 commits into
dotnet:masterfrom
swaroop-sridhar:depsfile
Apr 29, 2020
Merged

Fix PublishDepsFilePath setting#11462
swaroop-sridhar merged 3 commits into
dotnet:masterfrom
swaroop-sridhar:depsfile

Conversation

@swaroop-sridhar
Copy link
Copy Markdown
Contributor

Restore the semantics of PublishDepsFilePath to be location where the deps.json resides when published.
The PublishDepsFilePath property is used by external projects (ex: asp.net) which rely on this definition.

PublishDepsFilePath is empty (by default) for PublishSingleFile, since the deps.json file is embedde within the single-file bundle.

Add a test case for this property.

Restore the semantics of PublishDepsFilePath to be location where the deps.json resides when published.
The PublishDepsFilePath property is used by external projects (ex: asp.net) which rely on this definition.

PublishDepsFilePath is empty (by default) for PublishSingleFile, since the deps.json file is embedde within the single-file bundle.

Add a test case for this property.
Copy link
Copy Markdown

@dougbu dougbu left a comment

Choose a reason for hiding this comment

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

Works for me but this is @dsplaisted's parade

@dsplaisted
Copy link
Copy Markdown
Member

What would the guidance be for consumers of this property if they are run for a single file app? This change looks like it fixes ASP.NET because it reverts to the previous behavior for a non-single-file app. But if there's a target that wants to rewrite the deps file and it should work for single-file apps, what are they supposed to do?

@dougbu
Copy link
Copy Markdown

dougbu commented Apr 28, 2020

Hmm, @dsplaisted would it work to restore the previous (never-empty) values of $(PublishDepsFilePath) i.e. eliminate $(_DepsFilePath)?

@swaroop-sridhar
Copy link
Copy Markdown
Contributor Author

What would the guidance be for consumers of this property if they are run for a single file app? This change looks like it fixes ASP.NET because it reverts to the previous behavior for a non-single-file app. But if there's a target that wants to rewrite the deps file and it should work for single-file apps, what are they supposed to do?

If the meaning of "PublishDepsFilePath" is really the "actual published location" of the deps file, there's no such location in single-file bundle -- because the deps.json is embedded within the single-file bundle. Therefore, this property is unset for single-file apps. This behavior is similar to other location semantics in single-file apps. For example, Assembly.Location returns the empty string for any embedded assembly.

If a target wants to modify the deps file, it needs to insert itself between GeneratePublishDependencyFile and GenerateSingleFileBundle targets. To help with this, we could expose the _DepsFilePath target as IntermediateDepsFilePath which can be used in single-file or non-single-file cases.

@swaroop-sridhar
Copy link
Copy Markdown
Contributor Author

Hmm, @dsplaisted would it work to restore the previous (never-empty) values of $(PublishDepsFilePath) i.e. eliminate $(_DepsFilePath)?

I don't think this is a good idea -- because $(PublishDepsFilePath) will change meaning from
"published deps file path" to "intermediate deps file path" for single-file apps.

@swaroop-sridhar
Copy link
Copy Markdown
Contributor Author

@dsplaisted : Made the _DepsFilePath property public, as IntermediateDepsFilePath.

@dougbu
Copy link
Copy Markdown

dougbu commented Apr 28, 2020

From my perspective, the current meaning of $(PublishDepsFilePath) is "location of the .deps file after the GeneratePublishDependencyFile target runs". I don't think naming consistency across msbuild properties (aside from the leading underscore) is a good thing to aim for when dealing with legacy. That ship has sailed. And, a name like $(IntermediateDepsFilePath) is a strange one if you want to encourage developers to update a file before it's bundled and copied to the final publish or pack location.

I vote against requiring the world to use a new property instead of $(PublishDepsFilePath).

@swaroop-sridhar
Copy link
Copy Markdown
Contributor Author

@dougbu we only need to use IntermediateDepsFilePath if updating the deps.json file for single-file apps.

I think using IntermediateDepsFilePath will make the fact that the deps.file needs to be updated in the "intermediate" stage before bundling into a single-exe, more evident. But I'm not too stuck on the name to use.

I'm wary of keeping PublishDepsFilePath pointing to the obj\...\app.deps.json file for single-file apps, because consumers may try to change it post publish (since the file still exists) and expect it to work.

@dougbu
Copy link
Copy Markdown

dougbu commented Apr 28, 2020

@swaroop-sridhar understand your wariness. I lean toward avoiding breaking changes and you're leaning toward easily explainable general rules. The reason for my leaning is mainly that nobody reads the general rules. But my thoughts on single-file publish are theoretical -- I don't use that infrastructure. If $(PublishDepsFilePath) works like it used to for the non-single-file case, at least aspnetcore will be good.

And, if this also fixes the new NU5118 warnings, all the better.

@swaroop-sridhar
Copy link
Copy Markdown
Contributor Author

My suggestion is to take this fix, and unblock the SDK update.
We can then discuss what PublishDepsFilePath should look like on single-file apps.

@ViktorHofer
Copy link
Copy Markdown
Member

Can we please reach consensus here as this currently blocks both aspnetcore and arcade updating to a newer sdk. For aspnetcore this is even on the critical path for preview4.

@swaroop-sridhar
Copy link
Copy Markdown
Contributor Author

@dsplaisted please review.


<PropertyGroup>
<PublishDepsFilePath Condition=" '$(PublishDepsFilePath)' == ''">$(IntermediateOutputPath)$(ProjectDepsFileName)</PublishDepsFilePath>
<!-- _DepsPath is the location where the deps.json file is originally created
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this comment is out of date with the current code. I don't see a _DepsPath property.

var publishDepsFilePath = GetPropertyValue(projectPath, targetFramework, "PublishDepsFilePath");
var expectedDepsFilePath = $"{publishDir}{projectDepsFileName}";

publishDepsFilePath.Equals(expectedDepsFilePath).Should().BeTrue();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's better to write the assertion like this:

publishDepsFilePath.Should().Be(expectedDepsFilePath)

That gives more diagnosable failure messages.

(This also applies to the other assertions)

{
var testProject = SetupProject(singleFile: false);
var testAsset = _testAssetsManager.CreateTestProject(testProject);
var restoreCommand = new RestoreCommand(Log, testAsset.Path, testProject.Name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you can remove the explicit restore commands. The GetValuesCommand should restore by default for you.

@dsplaisted
Copy link
Copy Markdown
Member

Looks good, we can take this change. I did not think it was blocking for taking an updated SDK, I thought that there was a workaround.

@dougbu
Copy link
Copy Markdown

dougbu commented Apr 29, 2020

I thought that there was a workaround.

It's possible to create a workaround but I don't have one yet. And, if this is also at the root of the new NU5118 warnings, the only workaround there is to suppress the warnings i.e. to sweep things under the rug.

@swaroop-sridhar swaroop-sridhar merged commit c09668e into dotnet:master Apr 29, 2020
@dougbu
Copy link
Copy Markdown

dougbu commented Apr 29, 2020

Thanks @swaroop-sridhar and @dsplaisted. About how much time will likely pass between this merge and a new SDK version that dotnet-install.ps1 / dotnet-install.sh can install?

@dougbu
Copy link
Copy Markdown

dougbu commented Apr 29, 2020

Better question: Is completion of https://dev.azure.com/dnceng/internal/_build/results?buildId=624059&view=results plus ~15 minutes enough for this fix to be available?

@dsplaisted
Copy link
Copy Markdown
Member

@dougbu, no, once that build completes then it needs to get inserted into the installer repo (which is automated, though it sometimes needs manual intervention). Here's the most recent PR that updated the SDK in installer: dotnet/installer#7351

@dougbu
Copy link
Copy Markdown

dougbu commented Apr 30, 2020

Ah, then https://dev.azure.com/dnceng/internal/_build/results?buildId=624059 completion (soon) + ~15 minutes for Maestro++ machinations + ~2 hours for a dotnet/installer PR and a https://dev.azure.com/dnceng/internal/_build?definitionId=286 run + another ~15 minutes i.e. likely 2.5 hours from now (best case)?

@dougbu
Copy link
Copy Markdown

dougbu commented Apr 30, 2020

Never mind, the current pipeline just failed in the (Arcade) Signing validation step: https://dev.azure.com/dnceng/internal/_build/results?buildId=624059&view=logs&j=0a6c679f-72be-5867-422e-acb741a068a3&t=d8e44ddf-8ea2-5518-25e7-4300471a271a&l=20 More waiting ☹️

@dougbu
Copy link
Copy Markdown

dougbu commented Apr 30, 2020

(@dsplaisted @swaroop-sridhar the 'master' branch of dotnet/sdk started failing after an update from microsoft/msbuild. I don't see this error before https://dev.azure.com/dnceng/internal/_build/results?buildId=622370&view=logs&j=0a6c679f-72be-5867-422e-acb741a068a3&t=d8e44ddf-8ea2-5518-25e7-4300471a271a&l=20)

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.

4 participants