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
But it seems DependentUpon is not working this way - solution explorer displays Foo.xaml and Foo.xaml.cs as the separate files, but I need Foo.xaml.cs to be nested in Foo.xaml.
There is a warning generated: The parent file, '*.xaml', for file 'Foo.xaml.cs' cannot be found in the project file.
Regards!
Reacted by Aaron Hogue, NetherGranite and Andriy Savin
This pattern may also be useful for T4 templates and their generated output. What does %(Filename) expand to here? foo.xaml, foo.xaml.cs? does it need to be dependent on the one w/o the cs extension?
For those who're also using ReSharper it might be helpful - it seems I've found a bug which is affects only ReSharper - it reports for every named XAML element that the field is already declared - because it looks into the obj folder and sees .xaml.g.cs files. That's strange because I explicitly removed this folder from the included compile items:
<-- this not works for ReSharper for some reason -->
<CompileInclude="**\*.cs" />
<CompileRemove="obj\**" />
In order to support Depend Upon items in combination with globs, we added a new feature - dynamic depend upon items - the dependency between files is calculated dynamically when project is loaded and doesn't get persisted in the project file.
Documentation is pending, so here is a quick overview:
You can use the existing implementation of IDependentFilesProvider that uses metadata defined in the project items schema to identify dependent files:
Adrian Vinca (@adrianvmsft), thanks! I just checked and it doesn't work for me in the latest VS2017 RC - dependent .xaml.cs files are displayed separately. I'm using this XAML rule:
Great! I am glad that it worked!
Updating that page is already on my todo list - I actually pretty much did half of the work replying here :). Once I do that, I will close this issue.
Thanks!
where I18NReactive is a custom single file generator I wrote. The globbing and dependencies work at first glance.
Then I right click and select run custom tool to regen the resx.cs file. And not only does it update the file it also updates my csproj file. 👎 so now it is
Adrian Vinca (@adrianvmsft) Hello, I'm wondering why this feature looks so xaml-centered? At the documentation page there is nothing about how to make this work with other file types. For example, I'd like to link common appsettings json files which are not linked automatically (e.g. appsettingsCommon.json and appsettingsCommon.Development.json ). How do I accomplish this with this feature?
Activity
aienabled commentedon Feb 7, 2017
By the way, DependentUpon is applied to my XAML rule (and worked fine in VS2015) https://github.com/Microsoft/VSProjectSystem/blob/b70104c4781749369c995a48f83e64607a0c6594/doc/extensibility/automatic_DependentUpon_wireup.md but it doesn't work with globbing.
Here are the rules I'm using:
aienabled commentedon Feb 7, 2017
Ok, I've found a good workaround - added this to the CSPROJ:
clairernovotny commentedon Feb 7, 2017
This pattern may also be useful for T4 templates and their generated output. What does
%(Filename)expand to here?foo.xaml,foo.xaml.cs? does it need to be dependent on the one w/o thecsextension?aienabled commentedon Feb 7, 2017
For those who're also using ReSharper it might be helpful - it seems I've found a bug which is affects only ReSharper - it reports for every named XAML element that the field is already declared - because it looks into the
objfolder and sees.xaml.g.csfiles. That's strange because I explicitly removed this folder from the included compile items:Use this instead:
aienabled commentedon Feb 7, 2017
The resulting files globbing code for including
XAMLfiles with according.XAML.CScode-behind files in my case:Please note that you need to define the
Pagerule to properly processXAMLfiles with CPS. It was already discussed at issue #99.adrianvmsft commentedon Feb 13, 2017
In order to support Depend Upon items in combination with globs, we added a new feature - dynamic depend upon items - the dependency between files is calculated dynamically when project is loaded and doesn't get persisted in the project file.
Documentation is pending, so here is a quick overview:
You can use the existing implementation of IDependentFilesProvider that uses metadata defined in the project items schema to identify dependent files:
This snippet will make .aaa.cs and .aaa.txt files to be displayed as dependent on .aaa files
For more advanced relationships you can implement a new IDependentFilesProvider.
aienabled commentedon Feb 14, 2017
Adrian Vinca (@adrianvmsft), thanks! I just checked and it doesn't work for me in the latest VS2017 RC - dependent
.xaml.csfiles are displayed separately. I'm using thisXAMLrule:adrianvmsft commentedon Feb 14, 2017
You're right, I forgot to mention that you also need to define the DynamicDependentFile capability. Sorry about that.
Could you try adding the following to your project (e.g. in the .targets file):
aienabled commentedon Feb 15, 2017
Adrian Vinca (@adrianvmsft), thanks! It works now as expected.
It would be great if you also update the automatic_DependentUpon_wireup.md page to mention about this new feature.
Regards!
adrianvmsft commentedon Feb 15, 2017
Great! I am glad that it worked!
Updating that page is already on my todo list - I actually pretty much did half of the work replying here :). Once I do that, I will close this issue.
Thanks!
adrianvmsft commentedon Feb 17, 2017
Here is the PR with the documentation update, in case you would like to take a look: #187
bdovaz commentedon Sep 4, 2017
Anyone got this working? I'm able to compile it but I lost intellisense in VS 2017.
This is my csproj:
aienabled commentedon Sep 5, 2017
Borja Domínguez (@bdovaz) I responded there dotnet/project-system#1467 (comment)
bradphelan commentedon Oct 6, 2017
Here is a fun example of bad behaviour of globbing and the project system. I have
where I18NReactive is a custom single file generator I wrote. The globbing and dependencies work at first glance.
Then I right click and select run custom tool to regen the
resx.csfile. And not only does it update the file it also updates my csproj file. 👎 so now it isthat's kinda wierd no?
I also tried
bradphelan commentedon Oct 6, 2017
I made the above comment a new issue at dotnet/project-system#2873
andriysavin commentedon Feb 10, 2022
Adrian Vinca (@adrianvmsft) Hello, I'm wondering why this feature looks so xaml-centered? At the documentation page there is nothing about how to make this work with other file types. For example, I'd like to link common appsettings json files which are not linked automatically (e.g. appsettingsCommon.json and appsettingsCommon.Development.json ). How do I accomplish this with this feature?