用于嵌入外部 xml 文件的 Visual Studio 预构建操作
我正在使用 Visual Studio 2019 并使用 C# 开发 VSTO 应用程序。我通过 VSTOContrib 库使用 WPF 和 MVVM。该库使用命名约定通过搜索程序集在运行时耦合视图(xml 文件)和视图模型。
问题:
视图(xml 文件)由非开发人员在单独的文件夹中进行外部管理。并且该文件夹的路径是不可更改的。
我得出的结论是,最好的行动方案是在构建时使用预构建操作嵌入文件,但是经过几个小时的研究,我无法找到有关该主题的任何信息。
以前有人这样做过吗?
I'm on visual studio 2019 and developing a VSTO application using C#. I'm using WPF and MVVM by use of VSTOContrib library. The library uses naming convention to couple view (xml file) and viewmodel at runtime by searching the assembly.
The problem:
The view (xml file) is managed externally by non-developers in a separate folder. And this folder's path is unchangeable.
I've come to the conclusion the best course of action would be to embed the file at build time using pre-build actions however after hours of research I've been unable to find any information on the subject.
Has anyone done this before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将项目组添加到项目文件中:
它可以是绝对路径或相对路径。编译器将为您处理嵌入文件的过程。 (可选)添加
LogicalName
属性来设置嵌入资源的名称。如果没有指定,msbuild将使用文件名为您生成一个名称。Add an itemgroup to your project file:
It can be an absolute or a relative path. The compiler will take care of the process of embedding the file for you. Optionally add the
LogicalName
attribute to set the name of the embedded resource. It not specified, msbuild will use the filename to generate a name for you.