Can the "Add Project Reference Post Action" be used to reference an existing project? #7833
-
I have a project template that creates several projects and inserts them into an existing solution. I'm trying to include these newly generated projects in another already existing project within the solution. However, specifying the relative path of the existing .csproj file doesn't seem to work if it wasn't generated as part of the initial template creation process. Is there a way to achieve this? What works:
What doesn't work:
My environment: My current post action looks like this: {
"description": "Adding a reference to another project",
"actionId": "B17581D1-C5C9-4489-8F0A-004BE667B814",
"continueOnError": true,
"applyFileRenamesToArgs": ["targetFiles"],
"args": {
"targetFiles": [
"Existing.Web.csproj"
],
"referenceType": "project",
"reference": "NewProject.csproj"
}
} And my directory structure:
Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After reviewing the source it appears that the current version does not support this functionality, although it potentially could or should. This also applies to #7508. The reason behind this limitation is that the PostActionProcessor only finds project files to add references to if:
If the last two checks fail to find issues the PostActionProcessor gives up and throws I'm creating an issue and pull request to add a third option: If no project files are found after the last two checks, try to find a project file in the relative path as specified in the "targetFiles" without checking for a matching IFileChange (i.e. an existing .csproj) |
Beta Was this translation helpful? Give feedback.
After reviewing the source it appears that the current version does not support this functionality, although it potentially could or should. This also applies to #7508.
The reason behind this limitation is that the PostActionProcessor only finds project files to add references to if:
The files listed in the "targetFiles" property within template.json can be associated with an IFileChange. Which is not the case for existing project files because the TemplateEngine does not generate corresponding IFileChange instances.
No "targetFiles" are specified and the files are in the root of the output directory or its parent. Which doesn't work for existing projects since the .csproj file for su…