Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,18 @@ To use the package, install `Refitter.MSBuild`
The MSBuild package includes a custom `.target` file which executes the `RefitterGenerateTask` custom task and looks something like this:

```xml
<Target Name="Refitter" BeforeTargets="BeforeBuild">
<UsingTask TaskName="RefitterGenerateTask"
AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll"
Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" />
<Target Name="RefitterGenerate" BeforeTargets="BeforeCompile">
<RefitterGenerateTask ProjectFileDirectory="$(MSBuildProjectDirectory)"
DisableLogging="$(RefitterNoLogging)"/>
DisableLogging="$(RefitterNoLogging)">
<Output TaskParameter="GeneratedFiles" ItemName="RefitterGeneratedFiles" />
</RefitterGenerateTask>
<ItemGroup>
<Compile Include="**/*.cs" />
<Compile Include="@(RefitterGeneratedFiles)" />
</ItemGroup>
</Target>
</Target>
```
Comment thread
christianhelle marked this conversation as resolved.

The `RefitterGenerateTask` task will scan the project folder for `.refitter` files and executes them all. By default, telemetry collection is enabled, and to opt-out of it you must specify `<RefitterNoLogging>true</RefitterNoLogging>` in the `.csproj` `<PropertyGroup>`
Expand Down
15 changes: 10 additions & 5 deletions src/Refitter.MSBuild/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
## MSBuild Tasks for Refitter
# MSBuild Tasks for Refitter

Refitter is available as custom MSBuild tasks that includes the Refitter CLI executable for generating a REST API Client using the [Refit](https://github.com/reactiveui/refit) library. Refitter can generate the Refit interface from OpenAPI specifications. Refitter could format the generated Refit interface to be managed by [Apizr](https://www.apizr.net) (v6+) and generate some registration helpers too.

The MSBuild package includes a custom `.target` file which executes the `RefitterGenerateTask` custom task and looks something like this:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Typo: .target → .targets

File extension should be .targets.

Apply:

-The MSBuild package includes a custom `.target` file which executes the `RefitterGenerateTask` custom task and looks something like this:
+The MSBuild package includes a custom `.targets` file which executes the `RefitterGenerateTask` custom task and looks like this:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The MSBuild package includes a custom `.target` file which executes the `RefitterGenerateTask` custom task and looks something like this:
The MSBuild package includes a custom `.targets` file which executes the `RefitterGenerateTask` custom task and looks like this:
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/README.md around line 5, update the typo where the file
extension is written as ".target" to the correct ".targets"; edit the sentence
so it reads ".targets" (and scan the file for any other occurrences of ".target"
to correct to ".targets" if present).


```xml
<Target Name="Refitter" BeforeTargets="BeforeBuild">
<UsingTask TaskName="RefitterGenerateTask"
AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll"
Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" />
Comment thread
christianhelle marked this conversation as resolved.
<Target Name="RefitterGenerate" BeforeTargets="BeforeCompile">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Use CoreCompile (and CompileDesignTime) instead of BeforeCompile

BeforeCompile isn’t a standard target; your task may never run. Hook into CoreCompile; add CompileDesignTime so IDE design-time builds see generated files.

Apply:

-<Target Name="RefitterGenerate" BeforeTargets="BeforeCompile">
+<Target Name="RefitterGenerate" BeforeTargets="CoreCompile;CompileDesignTime"
+        Condition=" '$(IsCrossTargetingBuild)' != 'true' and Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Target Name="RefitterGenerate" BeforeTargets="BeforeCompile">
<Target Name="RefitterGenerate" BeforeTargets="CoreCompile;CompileDesignTime"
Condition=" '$(IsCrossTargetingBuild)' != 'true' and Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')">
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/README.md around line 11, the MSBuild Target uses
BeforeCompile which is not a standard target and can prevent the task from
running; update the Target's BeforeTargets to hook into CoreCompile and
CompileDesignTime instead so the task runs in normal and design-time builds
(replace BeforeCompile with BeforeTargets="CoreCompile;CompileDesignTime").

<RefitterGenerateTask ProjectFileDirectory="$(MSBuildProjectDirectory)"
DisableLogging="$(RefitterNoLogging)"/>
DisableLogging="$(RefitterNoLogging)">
<Output TaskParameter="GeneratedFiles" ItemName="RefitterGeneratedFiles" />
</RefitterGenerateTask>
<ItemGroup>
<Compile Include="**/*.cs" />
<Compile Include="@(RefitterGeneratedFiles)" />
</ItemGroup>
</Target>
</Target>
```

The `RefitterGenerateTask` task will scan the project folder for `.refitter` files and executes them all. By default, telemetry collection is enabled, and to opt-out of it you must specify `<RefitterNoLogging>true</RefitterNoLogging>` in the `.csproj` `<PropertyGroup>`
Expand Down
12 changes: 9 additions & 3 deletions src/Refitter.MSBuild/Refitter.MSBuild.targets
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<Project>

<Target Name="Refitter" BeforeTargets="BeforeBuild">
<UsingTask TaskName="RefitterGenerateTask"
AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll"
Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" />
Comment on lines +3 to +5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fully qualify TaskName for reliability

Avoid ambiguous or unresolvable types.

Apply:

-    <UsingTask TaskName="RefitterGenerateTask" 
+    <UsingTask TaskName="Refitter.MSBuild.RefitterGenerateTask" 
                AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll" 
                Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<UsingTask TaskName="RefitterGenerateTask"
AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll"
Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" />
<UsingTask TaskName="Refitter.MSBuild.RefitterGenerateTask"
AssemblyFile="$(MSBuildThisFileDirectory)Refitter.MSBuild.dll"
Condition="Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')" />
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/Refitter.MSBuild.targets around lines 3 to 5, the
UsingTask uses an unqualified TaskName "RefitterGenerateTask" which can lead to
ambiguous or unresolvable task types; update TaskName to the fully-qualified
type name including its namespace (for example
NamespaceName.RefitterGenerateTask) so MSBuild can reliably locate the type in
the Refitter.MSBuild.dll, leaving AssemblyFile and Condition unchanged.


<Target Name="RefitterGenerate" BeforeTargets="BeforeCompile">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Target doesn’t run: BeforeCompile isn’t a standard hook

Switch to CoreCompile; add CompileDesignTime for IDEs; also guard with a Condition to avoid failures when the DLL is missing and to skip the outer cross-targeting build.

Apply:

-    <Target Name="RefitterGenerate" BeforeTargets="BeforeCompile">
+    <Target Name="RefitterGenerate" BeforeTargets="CoreCompile;CompileDesignTime"
+            Condition=" '$(IsCrossTargetingBuild)' != 'true' and Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Target Name="RefitterGenerate" BeforeTargets="BeforeCompile">
<Target Name="RefitterGenerate" BeforeTargets="CoreCompile;CompileDesignTime"
Condition=" '$(IsCrossTargetingBuild)' != 'true' and Exists('$(MSBuildThisFileDirectory)Refitter.MSBuild.dll')">
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/Refitter.MSBuild.targets around line 7, the Target is
wired to BeforeCompile which is not a standard hook; change BeforeTargets to
CoreCompile and also include CompileDesignTime so IDE/design-time builds run it.
Additionally add a Condition on the Target to skip outer cross-targeting builds
and avoid failures when the tool DLL is missing (e.g. check
'$(IsCrossTargetingBuild)' != 'true' and use Exists(...) against the
task/processor DLL path or a defined property), so the target only runs when not
in the outer cross-targeting pass and the required DLL exists.

<RefitterGenerateTask ProjectFileDirectory="$(MSBuildProjectDirectory)"
DisableLogging="$(RefitterNoLogging)"/>
DisableLogging="$(RefitterNoLogging)">
<Output TaskParameter="GeneratedFiles" ItemName="RefitterGeneratedFiles" />
</RefitterGenerateTask>
<ItemGroup>
<Compile Include="**/*.cs" />
<Compile Include="@(RefitterGeneratedFiles)" />
</ItemGroup>
</Target>

Expand Down
144 changes: 140 additions & 4 deletions src/Refitter.MSBuild/RefitterGenerateTask.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Diagnostics;
using System.Reflection;
using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using MSBuildTask = Microsoft.Build.Utilities.Task;

namespace Refitter.MSBuild;
Expand All @@ -10,6 +12,9 @@ public class RefitterGenerateTask : MSBuildTask

public bool DisableLogging { get; set; }

[Output]
public ITaskItem[] GeneratedFiles { get; set; }

public override bool Execute()
{
TryLogCommandLine($"Starting {nameof(RefitterGenerateTask)}");
Expand All @@ -22,40 +27,75 @@ public override bool Execute()

TryLogCommandLine($"Found {files.Length} .refitter files...");

var generatedFiles = new List<string>();

foreach (var file in files)
{
TryLogCommandLine($"Processing {file}");
TryExecuteRefitter(file);
var generated = TryExecuteRefitter(file);
if (generated != null)
{
generatedFiles.AddRange(generated);
}
}

GeneratedFiles = generatedFiles.Select(f => new Microsoft.Build.Utilities.TaskItem(f)).ToArray();
Comment thread
christianhelle marked this conversation as resolved.
TryLogCommandLine($"Generated {GeneratedFiles.Length} files");

return true;
}
Comment on lines 45 to 46

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Return failure when errors are logged

MSBuild tasks should return false on error to stop the build.

-        return true;
+        return !Log.HasLoggedErrors;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return true;
}
return !Log.HasLoggedErrors;
}
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/RefitterGenerateTask.cs around lines 45-46, the Execute
method currently always returns true; change it to return false when MSBuild
errors were logged so the build stops. Replace the unconditional return true
with a return that checks the task logger (e.g. return !Log.HasLoggedErrors or
return !(this.Log?.HasLoggedErrors ?? false)) so the method returns false if any
errors were logged.


private void TryExecuteRefitter(string file)
private List<string>? TryExecuteRefitter(string file)
{
try
{
StartProcess(file);
return StartProcess(file);
}
catch (Exception e)
{
TryLogErrorFromException(e);
return null;
}
}

private void StartProcess(string file)
private List<string> StartProcess(string file)
{
// First, determine what files will be generated by parsing the .refitter file
var expectedFiles = GetExpectedGeneratedFiles(file);

var assembly = Assembly.GetExecutingAssembly();
var packageFolder = Path.GetDirectoryName(assembly.Location);
var seperator = Path.DirectorySeparatorChar;

// Try multiple possible locations for the Refitter CLI
var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll";

// For development scenarios, try relative to the MSBuild project location

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use ArgumentList and proper quoting; fix typo in variable name.

String-building Arguments will break with spaces and invites subtle bugs. Prefer ProcessStartInfo.ArgumentList. Also rename 'seperator' → 'separator'.

-        var packageFolder = Path.GetDirectoryName(assembly.Location);
-        var seperator = Path.DirectorySeparatorChar;
+        var packageFolder = Path.GetDirectoryName(assembly.Location);
+        var separator = Path.DirectorySeparatorChar;
@@
-        var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll";
+        var refitterDll = $"{packageFolder}{separator}..{separator}refitter.dll";

And below (see next comment) replace Arguments with ArgumentList.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private List<string> StartProcess(string file)
{
// First, determine what files will be generated by parsing the .refitter file
var expectedFiles = GetExpectedGeneratedFiles(file);
var assembly = Assembly.GetExecutingAssembly();
var packageFolder = Path.GetDirectoryName(assembly.Location);
var seperator = Path.DirectorySeparatorChar;
// Try multiple possible locations for the Refitter CLI
var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll";
// For development scenarios, try relative to the MSBuild project location
private List<string> StartProcess(string file)
{
// First, determine what files will be generated by parsing the .refitter file
var expectedFiles = GetExpectedGeneratedFiles(file);
var assembly = Assembly.GetExecutingAssembly();
var packageFolder = Path.GetDirectoryName(assembly.Location);
var separator = Path.DirectorySeparatorChar;
// Try multiple possible locations for the Refitter CLI
var refitterDll = $"{packageFolder}{separator}..{separator}refitter.dll";
// For development scenarios, try relative to the MSBuild project location

if (!File.Exists(refitterDll))
{
refitterDll = $"{packageFolder}{seperator}..{seperator}..{seperator}..{seperator}Refitter{seperator}bin{seperator}Debug{seperator}net8.0{seperator}refitter.dll";
}

// If still not found, try in the current project directory
if (!File.Exists(refitterDll))
{
refitterDll = Path.Combine(ProjectFileDirectory!, "..", "..", "src", "Refitter", "bin", "Debug", "net8.0", "refitter.dll");
}

var args = $"{refitterDll} --settings-file {file}";
if (DisableLogging)
{
args += " --no-logging";
}

Comment thread
christianhelle marked this conversation as resolved.
if (!File.Exists(refitterDll))
{
TryLogError($"Refitter CLI not found at: {refitterDll}");
TryLogError($"Assembly location: {assembly.Location}");
TryLogError($"Package folder: {packageFolder}");
return new List<string>();
}

Comment on lines +75 to +82

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Treat missing CLI as a hard failure.

Returning an empty list hides the root cause and keeps the build green.

-            TryLogError($"Refitter CLI not found at: {refitterDll}");
-            TryLogError($"Assembly location: {assembly.Location}");
-            TryLogError($"Package folder: {packageFolder}");
-            return new List<string>();
+            TryLogError($"Refitter CLI not found at: {refitterDll}");
+            TryLogError($"Assembly location: {assembly.Location}");
+            TryLogError($"Package folder: {packageFolder}");
+            throw new FileNotFoundException("Refitter CLI not found.", refitterDll);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!File.Exists(refitterDll))
{
TryLogError($"Refitter CLI not found at: {refitterDll}");
TryLogError($"Assembly location: {assembly.Location}");
TryLogError($"Package folder: {packageFolder}");
return new List<string>();
}
if (!File.Exists(refitterDll))
{
TryLogError($"Refitter CLI not found at: {refitterDll}");
TryLogError($"Assembly location: {assembly.Location}");
TryLogError($"Package folder: {packageFolder}");
throw new FileNotFoundException("Refitter CLI not found.", refitterDll);
}
🤖 Prompt for AI Agents
In src/Refitter.MSBuild/RefitterGenerateTask.cs around lines 91 to 98, the code
currently logs missing Refitter CLI and then returns an empty list, which masks
the failure and keeps the build green; change this to a hard failure by throwing
an exception (e.g., FileNotFoundException) after logging the error(s) so the
build fails visibly — include the paths (refitterDll, assembly.Location,
packageFolder) in the exception message to aid diagnostics.

TryLogCommandLine($"Starting dotnet {args}");

using var process = new Process
Expand All @@ -79,6 +119,84 @@ private void StartProcess(string file)
process.BeginErrorReadLine();
process.BeginOutputReadLine();
process.WaitForExit();

// Return the list of files that should have been generated
return expectedFiles.Where(File.Exists).ToList();
}

private List<string> GetExpectedGeneratedFiles(string refitterFilePath)
{
try
{
var refitterFileDirectory = Path.GetDirectoryName(refitterFilePath) ?? string.Empty;
var refitterContent = File.ReadAllText(refitterFilePath);

// Parse JSON properties using simple regex patterns
var outputFolder = ExtractJsonStringValue(refitterContent, "outputFolder");
var outputFilename = ExtractJsonStringValue(refitterContent, "outputFilename");
var generateMultipleFiles = ExtractJsonBoolValue(refitterContent, "generateMultipleFiles");
var contractsOutputFolder = ExtractJsonStringValue(refitterContent, "contractsOutputFolder");
var hasDependencyInjectionSettings = refitterContent.Contains("\"dependencyInjectionSettings\"");

// If contractsOutputFolder is specified, automatically enable multiple files
if (!string.IsNullOrWhiteSpace(contractsOutputFolder))
{
generateMultipleFiles = true;
}

// Default output filename based on .refitter filename if not specified
if (string.IsNullOrWhiteSpace(outputFilename))
{
var refitterFileName = Path.GetFileNameWithoutExtension(refitterFilePath);
outputFilename = $"{refitterFileName}.cs";
}

var generatedFiles = new List<string>();

if (generateMultipleFiles)
{
// Multiple files mode
var baseOutputFolder = !string.IsNullOrWhiteSpace(outputFolder) ? outputFolder : "./Generated";
var interfaceOutputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, baseOutputFolder, "RefitInterfaces.cs"));
var contractsOutputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory,
!string.IsNullOrWhiteSpace(contractsOutputFolder) ? contractsOutputFolder : baseOutputFolder,
"Contracts.cs"));
var diOutputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, baseOutputFolder, "DependencyInjection.cs"));

generatedFiles.Add(interfaceOutputPath);
generatedFiles.Add(contractsOutputPath);

// DependencyInjection.cs is only generated if dependencyInjectionSettings are specified
if (hasDependencyInjectionSettings)
{
generatedFiles.Add(diOutputPath);
}
}
else
{
// Single file mode
string outputPath;
if (!string.IsNullOrWhiteSpace(outputFolder))
{
// outputFolder is specified
outputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, outputFolder, outputFilename));
}
else
{
// No outputFolder specified - generate in current directory (default behavior)
outputPath = Path.GetFullPath(Path.Combine(refitterFileDirectory, outputFilename));
}
generatedFiles.Add(outputPath);
}

TryLogCommandLine($"Expected generated files: {string.Join(", ", generatedFiles)}");
return generatedFiles;
}
catch (Exception ex)
{
TryLogError($"Error parsing .refitter file {refitterFilePath}: {ex.Message}");
return new List<string>();
}
}
Comment thread
christianhelle marked this conversation as resolved.

private void TryLogErrorFromException(Exception e)
Expand Down Expand Up @@ -116,4 +234,22 @@ private void TryLogError(string text)
// ignore
}
}

private static string? ExtractJsonStringValue(string json, string propertyName)
{
// Simple regex to extract string values from JSON
// Pattern: "propertyName": "value" or "propertyName":"value"
var pattern = $@"""{Regex.Escape(propertyName)}""\s*:\s*""([^""]*)""";
var match = Regex.Match(json, pattern, RegexOptions.IgnoreCase);
return match.Success ? match.Groups[1].Value : null;
}
Comment thread
christianhelle marked this conversation as resolved.

private static bool ExtractJsonBoolValue(string json, string propertyName)
{
// Simple regex to extract boolean values from JSON
// Pattern: "propertyName": true or "propertyName":false
var pattern = $@"""{Regex.Escape(propertyName)}""\s*:\s*(true|false)";
var match = Regex.Match(json, pattern, RegexOptions.IgnoreCase);
return match.Success && string.Equals(match.Groups[1].Value, "true", StringComparison.OrdinalIgnoreCase);
}
}
9 changes: 4 additions & 5 deletions test/MSBuild/build.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
Remove-Item bin -Force -Recurse
Remove-Item obj -Force -Recurse
dotnet build-server shutdown
nuget locals global-packages -clear
Remove-Item ./refitter.msbuild -Recurse -Force
dotnet nuget locals global-packages --clear
Remove-Item Refitter.MSBuild.*.nupkg -Force
Remove-Item Petstore.cs
dotnet restore ../../src/Refitter.sln
dotnet clean -c release ../../src/Refitter.sln
dotnet build -c release ../../src/Refitter/Refitter.csproj
dotnet build -c release ../../src/Refitter.MSBuild/Refitter.MSBuild.csproj
dotnet pack -c release ../../src/Refitter.MSBuild/Refitter.MSBuild.csproj -o .
nuget add .\Refitter.MSBuild.1.0.0.nupkg -source .
dotnet add package .\Refitter.MSBuild.1.0.0.nupkg --source .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid command: dotnet add package does not accept a .nupkg path.

This will fail. Use the package ID and point to the folder as a source (the pack step already put the .nupkg in .).

-dotnet add package .\Refitter.MSBuild.1.0.0.nupkg --source .
+# Register current folder as a source (optional if you pass --source . each time)
+# dotnet nuget add source . --name LocalRefitter
+dotnet add package Refitter.MSBuild --source .
🤖 Prompt for AI Agents
In test/MSBuild/build.ps1 around line 12, the script incorrectly calls "dotnet
add package" with a .nupkg file path which is invalid; replace that call with
"dotnet add package" using the package ID and optionally the version, and point
--source to the folder containing the .nupkg (e.g. use the package ID
Refitter.MSBuild and --version 1.0.0 with --source .) so the CLI pulls the
package from the local folder.

dotnet restore
dotnet add package Refitter.MSBuild -s .
dotnet build -v d -filelogger
dotnet add package Refitter.MSBuild --source .
Comment thread
christianhelle marked this conversation as resolved.
dotnet run -v d -filelogger
Comment thread
christianhelle marked this conversation as resolved.
dotnet remove package Refitter.MSBuild
Remove-Item Refitter.MSBuild.*.nupkg -Force
Loading