Pregunta

My program adds files to a VB.NET solution. What I want is that the project, when files are added to it, is refreshes or prompted to refresh. Now what I am currently doing is unloading and reloading the project. This is fine, but I noticed that my newly added files are not included in the project, and I have to manually include them by clicking them.

How can I make my project add all files that are not included and refresh when new ones are added?

Thanks

My code to add.

enter image description here

¿Fue útil?

Solución

A lot of files can exist in folders and subfolders under the solution (sln file). not all of these files are required to participate in projects. each project file (vbproj / csproj) maintains the inventory of files included in the project. you need to both place your files at appropriate places and update the vbproj file appropriately.

As it happens, the vbproj files are not simple indexes, they are full blown build scripts. they have a pretty intricate file format (XML) and a convoluted semantics. Appending nodes in that file works fine if you follow the existing pattern. but i suggest you look up MSBUILD first.

Please note that if the project you are mutating programmatically, is open in visual studio, then there are strong chances of inconsistency. make sure the project is not open in any visual studio. programmatically altering the program itself (or the same project) is not advisable.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top