none
Convert Framework without opening visual studio RRS feed

  • Question

  • Hi,

    We are writing an automation tool to convert .net framework along with other activities, I will be having the solutions in my location drive and pass this location as input parameter of my tool. Here I need to know the framework conversion part to automate without opening that solution in visual studio.

    kindly share the details if we have any option to achieve this.

    Thanks in advance.

    Tuesday, March 14, 2017 4:08 PM

All replies

  • Hi VisweswaraN,

    It seems that you we could use Microsoft.Build.Evaluation.Project to achieve it, here is sample convert v4.6.2 to v4.0 for your reference.

    string webProjPath = @"D:\Project\Msbuild\TestProject\WebApp\WebApp.csproj";
    
    var proj = ProjectCollection.GlobalProjectCollection.LoadProject(webProjPath);
    proj.SetProperty("TargetFrameworkVersion", "v4.0");
    proj.Save();

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 15, 2017 2:15 AM
    Moderator
  • Hi Cole Wu,

    Thank you for your response. The given code snippet worked for me, but I am trying to automate the entire change (.csproj & Web.config changes) which happens when we manually migrate using Visual  Studio 2013. (I missed to include this my question :) )


    Wednesday, March 15, 2017 7:18 AM
  • Maybe perform some experiments: open a solution, change the framework, and then exit Visual Studio. Then compare the new and original project files (using a tool). Then you will know what changes to apply in your automation tool. The XML files can be manipulated with XDocument or XmlDocument classes.

    Wednesday, March 15, 2017 7:34 AM
  • Yeah, we did and have the changes, but again not sure will that covers entire scenarios. As we noticed, there were some namespace getting removed in web.config when migrate to 4.5.1 thru VS2013. So to have that in safer side, looking for any inbuilt code, 

    P.S.

    We tried using powershell scripts, but it changes (Web.config) when execute inside Package Manager console. when execute outside project by passing sln file, it not update the web.config. 

    Wednesday, March 15, 2017 9:13 AM
  • Hi VisweswaraN VaradarajaN,

    As Viorel said, you could compare the different in your web.config and change the web.config file via XDocument.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 16, 2017 5:37 AM
    Moderator