Reputation: 956
I am creating some classes by C#
CodeDOM
, in run time. then i include cs files that i created by CodeDOM
in my project like this:
var p = new Microsoft.Build.Evaluation.Project(@"D:\imanSal\SmlpeApp\SmlpeApp\SmlpeApp.csproj");
p.AddItem("Compile", outputFileName + this.ClassName + ".cs");
p.Save();
p.Build();
Then im getting a File Modification detected warning because my project has been modified outside the environment, so I have to reload it. What must I do if I want to Reload my project programmatically in run time? what's the best solution for this?
Upvotes: 1
Views: 581
Reputation: 33698
You could include additional files to compile by specify them in the project file. For example, put dynamic creating file to Lib folder, then you can add this code to your project file (<Compile Include="Lib\*.cs" />),
after that these files will be included during the build.
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Lib\*.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
The file modification detected waring is the feature of Visual Studio, so there isn’t the way to load the project programmatically through MSBuild.
Upvotes: 1