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 Reference To A Project File Not Working When Target Project Folder Renamed #7465

Open
joshschnebly opened this issue Jan 16, 2024 · 1 comment

Comments

@joshschnebly
Copy link

Product

dotnet CLI (dotnet new)

Describe The Bug

When performing the Add Reference to Project File post-action, the action fails when the target project to add a reference to is in a folder that is renamed.

To Reproduce

Template Files

SUBDOMAIN_NAME
   Project1.csproj
Project2
   Project2.csproj

Template Input
SUBDOMAIN_NAME - Project1

.template.config

{...
"primaryOutputs": [
    {
      "path": "SUBDOMAIN_NAME/Project1.csproj"
    },
    {
      "path": "Project2/Project2.csproj"
    }
  ],
    {
      "description ": "Add project 2 reference to project 1",
      "manualInstructions": [
        {
          "text": "add project reference "
        }
      ],
      "applyFileRenamesToArgs": [ "targetFiles", "reference" ],
      "applyFileRenamesToManualInstructions": true,
      "args": {
        "targetFiles": [
          "./SUBDOMAIN_NAME/Project1.csproj"
        ],
        "referenceType": "project",
        "reference": "./Project2/Project2.csproj",
        "projectFileExtensions": ".csproj"
      },
      "actionId": "B17581D1-C5C9-4489-8F0A-004BE667B814",
      "continueOnError": true
    }
  ]
}

Result
The message "Unable to determine which project file to add the reference to." is shown in the template output.

If the folder path is hard-coded to match the template input for SUBDOMAIN_NAME, then the action succeeds.

Template Files

Project1
  Project1.csproj
Project2
  Project2.csproj

Template Input
SUBDOMAIN_NAME - Project1

.template.config
(same as above)

Result
The message "Successfully added a reference to the project file." is shown in the template output.

Is this a bug or is this the expected behavior?

dotnet Info

output

.NET SDK:
Version: 8.0.101
Commit: 6eceda187b
Workload version: 8.0.100-manifests.69afb982

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.101\

.NET workloads installed:
Workload version: 8.0.100-manifests.69afb982
There are no installed workloads to display.

Host:
Version: 8.0.1
Architecture: x64
Commit: bf5e279d92

.NET SDKs installed:
3.1.426 [C:\Program Files\dotnet\sdk]
6.0.316 [C:\Program Files\dotnet\sdk]
7.0.101 [C:\Program Files\dotnet\sdk]
7.0.311 [C:\Program Files\dotnet\sdk]
7.0.404 [C:\Program Files\dotnet\sdk]
8.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Visual Studio Version

No response

Additional context

No response

@Ruby-Dev-Droid
Copy link

Hi @joshschnebly, Did you ever find the cause of your issue here and the solution to it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants