如何解决Visual Studio递归折叠解决方案项
我正在尝试折叠所有XAML依赖文件。
<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>
我可以折叠JS,但TS定义失败
我试图创建一个“临时”项目集合,并尝试迭代和解析路径……没有成功VS不再加载项目了
<ToFold Include=".\**\*.xaml" />
<None Include="@(ToFold->%(RecursiveDir)%(FileName).js')" DependentUpon="@(ToFold)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
我以“另一种方式”尝试了相同的方式... ...:(
<ToFold Include=".\**\*.xaml" />
<None Include="@(ToFold->%(ToFold).js')" DependentUpon="@(ToFold)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
问题
- 是否可以使用
x->%(RecursiveDir)%(FileName
以外的其他方式解析路径? - 是否可以折叠
*.dash.ext
之类的物品?怎么样? - 或者有人可以帮助我实现这一目标?!
注意
xaml.ts
是自动生成的,并以某种方式自动折叠
解决方法
我认为问题在于:
对于KYCHome.xaml.d.ts
文件,%(FileName)
的值为KYCHome.xaml.d
而不是KYCHome.xaml
。因此,当您使用它时,它将找不到KYCHome.xaml
文件。
所以我能想到的方法是拦截FileName
,删除.d
,然后更改后的值就是我们所需要的。
解决方案
这是我使用的:
<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>
注意:您应删除.\
节点下的DependentUpon
。 否则,有时DependentUpon
在重新启动项目或卸载项目时将不起作用。
我是法国人,我认为这对我实现自己的目标是一个障碍。我是说折叠物品,但是如果我说嵌套物品,我会很快从Google那里得到答案。
Visual Studio具有嵌套项目功能
我从这里Path segment pattern得到了答案,这是我在.filenesting.json
解决方案文件中添加的节点
"dependentFileProviders": {
"add": {
"addedExtension": {},"pathSegment": {},"fileSuffixToExtension": {
"add": {
".xaml.d.ts": [".xaml"]
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。