Updating PackageReferences #4130
Unanswered
AlanHoiland
asked this question in
Q&A
Replies: 1 comment
-
@AlanHoiland The recommended way to update package references via command-line is to use the e.g.
StartProcess("dotnet", "add package NaturalStringExtensions --version 3.0.0"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I thought this would be easy but I'm missing something. How do you update PackageReferences version numbers?
Visual Studio 2022
netstandard 2.0 projects
I have a Shared package that is used in other projects. I can update the Shared package version, build, pack, and publish. But then want to update the PackageReference in another project and have hit a brick wall. I've tried NuGetUpdate and of course it is looking for a packages.config file that doesn't exist. I've tried Cake.Incubator and it can get the PackageReferences but I don't see a way to write any changes back to the project. I feel like I'm missing something basic but all my google searches turn up empty.
Here's my cake script:
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
#tool Bumpy
#addin Cake.Bumpy
#addin nuget:?package=Cake.ExtendedNuGet&version=5.0.0
#addin nuget:?package=Cake.Incubator&version=8.0.0
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(ctx =>
{
// Executed BEFORE the first task.
Information("Running tasks...");
});
Teardown(ctx =>
{
// Executed AFTER the last task.
Information("Finished running tasks.");
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
var versionTask = Task("Version")
.Does(() =>
{
BumpyNew();
});
var cleanTask = Task("Clean")
.IsDependentOn(versionTask)
.Does(() =>
{
CleanDirectory("./Shared/bin/release");
CleanDirectory("./Shared/bin/debug");
});
var restoreTask = Task("Restore")
.IsDependentOn(cleanTask)
.Does(() =>
{
DotNetRestore("./");
});
var buildTask = Task("Build")
.IsDependentOn(restoreTask)
.Does(() =>
{
DotNetBuild("./Shared", new DotNetBuildSettings{
NoRestore = true
});
});
var packageTask = Task("Package")
.IsDependentOn(buildTask)
.Does(() =>
{
DotNetPack("./Shared", new DotNetPackSettings
{
NoRestore = true,
NoBuild = true
});
});
var publishTask = Task("Publish")
.IsDependentOn(packageTask)
.Does(() => {
var settings = new DotNetNuGetPushSettings
{
Source = "mysourcepath",
ApiKey = "ApiKey"
};
});
var updateSharedTask = Task("UpdateShared")
//.IsDependentOn(publishTask)
.Does(() =>
{
var props = ParseProject("./Project1/Project1.csproj", "Debug");
// NuGetUpdate(@"./Library.sln", new NuGetUpdateSettings
// {
// Id = new [] { "Shared" }
// });
});
Task("Default")
.IsDependentOn(updateSharedTask)
.Does(() => {
Information("Hello Cake!");
});
RunTarget(target);
Beta Was this translation helpful? Give feedback.
All reactions