Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Failure to update .NET AspNet WebApi projects #242

Merged
merged 4 commits into from
Apr 30, 2018
Merged

Failure to update .NET AspNet WebApi projects #242

merged 4 commits into from
Apr 30, 2018

Conversation

skolima
Copy link
Collaborator

@skolima skolima commented Apr 12, 2018

When trying to run NuKeeper on a .NET "classic" WebApi project that has been updated to use PackageReference, attempting to update packages will fail.

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.1.104\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

That's because a) we can't run NuGet on that (refuses to run without packages.config) and b) can't run dotnet add/remove as those will fail to import the webapi targets file. The workaround is to find Imports that have the problematic (unset) VSToolsPath variable reference and change them to conditional imports. They will work the same in VS build (as the import target is found then) but will be skipped by the dotnet core update commands, allowing NuKeeper to handle the project.

@skolima
Copy link
Collaborator Author

skolima commented Apr 12, 2018

Repro for #239

This allows the dotnet remove/add commands to work without trying to import a non-existent project
@skolima
Copy link
Collaborator Author

skolima commented Apr 27, 2018

The current approach works, but my use case is a bit more complex still - turns out the failure I have is on an imported project in an imported project. Will need to add import traversal :-|

@@ -45,7 45,7 @@ public class NuGetUpdatePackageCommand : IUpdatePackageCommand
}

var sources = GetSourcesCommandLine(_sources);
var arguments = $"update packages.config -Id {currentPackage.Id} -Version {newVersion} {sources}";
var arguments = $"update {currentPackage.Path.RelativePath} -Id {currentPackage.Id} -Version {newVersion} {sources}";
Copy link
Member

Choose a reason for hiding this comment

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

Check use of DirectoryName and RelativePath here.
I -think_ that the first one is everything but the file name, and the second one is the path from the checkout folder including the file name. You might just want the bare file name in the second one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, this change isn't needed - I've left it by accident from a different attempt at solving this.

This might help the random build errors, according to dotnet/sdk#2076
@skolima skolima merged commit 2926273 into NuKeeperDotNet:master Apr 30, 2018
@skolima skolima deleted the webapi-mixed-style branch April 30, 2018 14:14
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