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?
CodePudding user response:
Add an itemgroup to your project file:
<ItemGroup>
<EmbeddedResource Include="path/to/the/file.xml" LogicalName="Name.Of.The.Resource" />
</ItemGroup>
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.