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

add CacheGet and CacheSet tasks #10418

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Tasks/CacheGet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Build.Framework;

#nullable disable

namespace Microsoft.Build.Tasks
{
public class CacheGet : TaskExtension
{
[Required]
public string Key { get; set; }

[Output]
public string Value { get; set; }

public override bool Execute()
{
Value = (string)BuildEngine4.GetRegisteredTaskObject(Key, RegisteredTaskObjectLifetime.Build) ?? "";
return true;
}
}
}
24 changes: 24 additions & 0 deletions src/Tasks/CacheSet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Build.Framework;

#nullable disable

namespace Microsoft.Build.Tasks
{
public class CacheSet : TaskExtension
{
[Required]
public string Key { get; set; }

[Required]
public string Value { get; set; }

public override bool Execute()
{
BuildEngine4.RegisterTaskObject(Key, Value, RegisteredTaskObjectLifetime.Build, allowEarlyCollection: true);
return true;
}
}
}
2 changes: 2 additions & 0 deletions src/Tasks/Microsoft.Build.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@
<Compile Include="FileIO\VerifyFileHash.cs" />
<Compile Include="FileState.cs" />
<Compile Include="Copy.cs" />
<Compile Include="CacheGet.cs" />
<Compile Include="CacheSet.cs" />
<Compile Include="CreateCSharpManifestResourceName.cs" />
<Compile Include="CreateVisualBasicManifestResourceName.cs" />
<Compile Include="CreateItem.cs" />
Expand Down