Posts

Es werden Posts vom 2014 angezeigt.

Addin Development: Add MSBuild Import to your csproj without unload and reloading the project using DTE

Yesterday I started developing an Addin which have to add an Import clause to the selected Project. After asking Google I thought that I have to unload the Project, modify the csproj file (XML or Microsoft.Build) and after that reload the Project using DTE.


I think this is no good Option because if you have in-memory changes at the Project file it will be saved and you don't have the possibility for undoing the previouse changes or the adding of the Targets file.

So today I found the solution:
You have to use the "Microsoft.Build.Evaluation" Namespace.

Adding a import clause to the in memory loaded csproj:



foreach(var prj in Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.LoadedProjects)
{
  if (string.Compare(prj.FullPath, dteProject.FullName) == 0)
  {
    prj.Xml.AddImport(@"YourDesiredTargetFile.targets");
    prj.MarkDirty();
  }
}

All done ;)

WinCE 5/6/7 and WEH65 Development with VS2013

Bild
You may say: This is impossible... I say: It works... At our Company we develop Application for WEH Scanners. Since all of the devices Targets Windows CE 5/6/7 (including WEH65) we are forced to use Visual Studio 2008. At the beginning of 2014 we started to evaluate Visual Studio 2013 as the developing IDE for Smart Device Applications. Quickly I realized that this doesn't work, since Microsoft didn't integrate the Smart Device Platform in the new IDE. So, what can we do? Good News, after 2 Months of analyzing different debug engine implementations I have a more or less full working Solution ;) The Problem is not the Compiler, the Problem are the following components: 1.Debugger 2.Forms Designer 3.Project Sub-Type DebuggerThe first thing I analyzed was the debugger. First I had a look at mdbg, since this open source Project can debug application on smart devices. After that, I thought that I had to implement an AD7 Debug Engine. But since the documentation is very poor, I ran into ma…