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

Use PackageDownload in VS, fix design time build failures #3268

Merged
merged 8 commits into from May 29, 2019

Conversation

dsplaisted
Copy link
Member

@livarcocc livarcocc added this to the 3.0.1xx milestone May 28, 2019
@livarcocc livarcocc requested a review from a team May 28, 2019 17:08
Copy link
Contributor

@livarcocc livarcocc left a comment

Choose a reason for hiding this comment

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

Yeah, tests would be great.

I imagine you have validated this with VS?

@dsplaisted
Copy link
Member Author

Yes, I tested this with VS, and ran into some problems which ended up being #2322. With that fixed, it now appears to work great in VS.

@@ -12,28 +12,36 @@ namespace Microsoft.NET.Build.Tasks
{
internal static class LockFileExtensions
{
public static LockFileTarget GetTargetAndThrowIfNotFound(this LockFile lockFile, NuGetFramework framework, string runtime)
public static LockFileTarget GetTargetAndThrowIfNotFound(this LockFile lockFile, NuGetFramework framework, string runtime,
bool throwIfNotFound = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

The API shape here is getting weird. AndThrowIfNotFound vs. bool throwIfNotFound

Having trouble coming up with a better shape though. Feels like it should just be GetTarget with the parameters modifying the behavior, but that conflicts with real instance GetTarget that can return null.

@@ -980,7 +987,10 @@ private void WriteApphostsForShimRuntimeIdentifiers()

foreach (var runtimeIdentifier in _task.ShimRuntimeIdentifiers.Select(r => r.ItemSpec))
{
LockFileTarget runtimeTarget = _lockFile.GetTargetAndThrowIfNotFound(_targetFramework, runtimeIdentifier);
bool throwIfAssetsFileTargetNotFound = !_task.DesignTimeBuild;
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, the bool local feels like it's unnecessary. Would be easier to read (subjectively) as `throwIfNotFound: !_task.DesignTimeBuild. Earlier, though, the local is used more than once so it has some value, and then I can see wanting to be consistent between the methods. So I'm not sure...

@@ -142,8 +142,9 @@ Copyright (c) .NET Foundation. All rights reserved.
</ResolveAppHosts>

<PropertyGroup Condition="'$(UsePackageDownload)' == ''">
<UsePackageDownload Condition=" '$(MSBuildRuntimeType)' == 'Core'">true</UsePackageDownload>
<UsePackageDownload Condition=" '$(MSBuildRuntimeType)' != 'Core'">false</UsePackageDownload>
<UsePackageDownload Condition="'$(MSBuildRuntimeType)' == 'Core'">true</UsePackageDownload>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this anymore? I can't think of a case from here forward where we'd be using core msbuild but PackageDownloadSupported != true. If we don't need it now, might as well keep it out. I guess this whole thing will go away. but I think there's still some value in keeping the bridge code as small as possible until then. Less moving parts to think about.

@dsplaisted
Copy link
Member Author

Design time tests are now failing in CI because I updated them to run all the targets that ran on a design time build on my machine, and the version of VS used by the CI machines doesn't have a recent version of VS that defines all of those targets.

Copy link
Contributor

@nguerrera nguerrera left a comment

Choose a reason for hiding this comment

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

(See comment on incremental build perf)

@@ -230,6 +231,15 @@ Copyright (c) .NET Foundation. All rights reserved.
<ExpectedPlatformPackages Include="@(PackageReference)" Condition="'%(Identity)' == 'Microsoft.AspNetCore.All'" />
</ItemGroup>

<CheckForTargetInAssetsFile
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will be a perf regression, forcing the assets file to be read from disk on every incremental build. I think it used be like this in fact, and I folded it into ResolvePackageAssets for this reason.

This should fix dotnet#2322.  The issue is there could be a catch-22 where
there is an assets file with the wrong targets (because the RuntimeIdentifier
or TargetFramework has changed) and we need to do a design-time
build to nominate restore (which will write the right targets to the assets
file), but the build to get the nomination data fails because the assets
file has the wrong targets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants