I am trying to fold all XAML dependents files.
<None Include=".\**\*.xaml.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DependentUpon>.\%(RecursiveDir)%(FileName)</DependentUpon>
</None>
<None Include=".\**\*.xaml.d.ts">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DependentUpon>.\%(RecursiveDir)%(FileName)</DependentUpon>
</None>
I was able to fold JSs but TS definitions fail
I tried to create a "temp" items collection and tried to iterate and parse paths ... no success VS didn't load the project anymore
<ToFold Include=".\**\*.xaml" />
<None Include="@(ToFold->%(RecursiveDir)%(FileName).js')" DependentUpon="@(ToFold)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
I tried the same way in "another way" ... same way :(
<ToFold Include=".\**\*.xaml" />
<None Include="@(ToFold->%(ToFold).js')" DependentUpon="@(ToFold)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
x->%(RecursiveDir)%(FileName
?*.dash.ext
? How ?NOTE
xaml.ts
are auto generated and somehow auto folded
I think the issue is that:
For KYCHome.xaml.d.ts
file, the value of %(FileName)
is KYCHome.xaml.d
rather than KYCHome.xaml
. So when you use it, it will not find the KYCHome.xaml
file.
So the method I can think of is to intercept the FileName
, remove the .d
, and then the changed value is what we need.
Solution
This is what I used:
<ItemGroup>
<None Include=".\**\*.xaml.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<DependentUpon>%(RecursiveDir)%(FileName)</DependentUpon>
</None>
<None Include=".\**\*.xaml.d.ts">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<File>$([System.String]::Copy('%(Filename)').Replace('.d', ''))</File>
<DependentUpon>%(RecursiveDir)%(File)</DependentUpon>
</None>
</ItemGroup>
Note: you should remove the .\
under DependentUpon
node. Otherwise, sometimes, the DependentUpon
will not work when you restart your project or unload the project.