You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Discussion/QuestionA discussion or question about the project that will not be treated as a bug or feature request.Triage-ApprovedReviewed and prioritized
If I add via the Add new File dialog a new File from Text File template with the name TextFile1.customFileType, Visual Studio changes the csproj to following:
It is removing the new file from the custom ItemGroup.
Is there any workaround to stop this? This behavior makes us problems in SpecFlow, as VS is removing items from our ItemGroups (they are defined in a props file in the NuGet package), which we need in a MSBuild Task.
This happens in Visual Studio 2017 15.9.5 and Visual Studio 2017 16.0.0 Preview 1.1.
This is by-design. You are hitting two different things;
The default item type for extensions that do not have any registration is the <None/> item type.
Visual Studio tries very hard to avoid including an item in multiple item types within a project. It's already included in the <None /> item (the default glob), so it removes it from the <CustomFileTypeItemGroup/>
Thanks for pointing me in the right direction @davkean.
I read the documentation, but the examples were all for new project types. But I would need this in the normal C# and VB projects.
Is there an example how to extend them with a new registration? Is this possible at all or is a change to the project system needed?
Sorry for pinging again @davkean.
This issue is blocking us from releasing SpecFlow 3 with .NET Core support.
If it's not possible to extend the project system via VSIX or NuGet package, we have to find another way to solve this.
But this would mean some ugly changes on our side, that I want to avoid.
Ok, I got it to work within a NuGet package. But I got into a new problem.
When I add a new file with the .customFileType ending, it is removing it from the <None> ItemGroup. And with it, it is not displayed in the Solution Explorer.
In this example there is a remove and include of the customFileTypeCompile ItemGroup present. This doesn't happen in my real project.
Only the None ItemGroup Remove is in the real project.
But why is this added? Or why is the file not displayed in the Solution Explorer?
I got the file to display in the real project. There was a typo in one import statement.
But the removal in the None- ItemGroup is still there.
I want to minimize the changes to the csproj. Is it possible to not have this change?
Discussion/QuestionA discussion or question about the project that will not be treated as a bug or feature request.Triage-ApprovedReviewed and prioritized
Activity
davkean commentedon Jan 22, 2019
This is by-design. You are hitting two different things;
The default item type for extensions that do not have any registration is the
<None/>item type.Visual Studio tries very hard to avoid including an item in multiple item types within a project. It's already included in the
<None />item (the default glob), so it removes it from the<CustomFileTypeItemGroup/>You need registration for your
customFileTypeto avoid it being assigned to the<None/>item type. You can read more here: https://github.com/Microsoft/VSProjectSystem/blob/master/doc/extensibility/custom_item_types.md.SabotageAndi commentedon Jan 23, 2019
Thanks for pointing me in the right direction @davkean.
I read the documentation, but the examples were all for new project types. But I would need this in the normal C# and VB projects.
Is there an example how to extend them with a new registration? Is this possible at all or is a change to the project system needed?
SabotageAndi commentedon Feb 4, 2019
Sorry for pinging again @davkean.
This issue is blocking us from releasing SpecFlow 3 with .NET Core support.
If it's not possible to extend the project system via VSIX or NuGet package, we have to find another way to solve this.
But this would mean some ugly changes on our side, that I want to avoid.
Thanks for your help!
davkean commentedon Feb 4, 2019
You extend existing C#/VB the same way as a new project type - there's no difference.
SabotageAndi commentedon Mar 4, 2019
I tried the last days to get this to work, but I wasn't successful.
My code is here: https://github.com/SabotageAndi/CPSCustomItemTypeExample
It's based on this example: https://github.com/Microsoft/VSProjectSystem/tree/master/samples/CpsExtension
An example is also included: https://github.com/SabotageAndi/CPSCustomItemTypeExample/tree/master/examples/ReproItemGroupChange
When I add a
TextFile1.customFileTypefile, it is still generating the ItemGroup- Remove statement in the csproj.Any ideas what I am missing @davkean? Thanks!
SabotageAndi commentedon Mar 5, 2019
Ok, I noticed that I don't import the https://github.com/SabotageAndi/CPSCustomItemTypeExample/blob/master/src/CpsExtensionCustomItemType.Vsix/BuildSystem/CpsExtension.DesignTime.targets not in the project.
This seems to be necessary. Is this correct?
Can't be than the whole customization done in a NuGet package and not in a VSIX?
SabotageAndi commentedon Mar 8, 2019
Ok, I got it to work within a NuGet package. But I got into a new problem.
When I add a new file with the
.customFileTypeending, it is removing it from the<None>ItemGroup. And with it, it is not displayed in the Solution Explorer.CSProj before:
After:
In this example there is a remove and include of the
customFileTypeCompileItemGroup present. This doesn't happen in my real project.Only the
NoneItemGroup Remove is in the real project.But why is this added? Or why is the file not displayed in the Solution Explorer?
Project is here: https://github.com/SabotageAndi/CPSCustomItemTypeExample/blob/master/examples/ReproItemGroupChange/ReproItemGroupChange/ReproItemGroupChange.csproj
SabotageAndi commentedon Mar 8, 2019
I got the file to display in the real project. There was a typo in one import statement.
But the removal in the None- ItemGroup is still there.
I want to minimize the changes to the csproj. Is it possible to not have this change?
dannyBies commentedon Mar 20, 2019
Any update on this? I would love to be able to use a stable version of Specflow running on .NET Core!