none
VSProject.References.Add method is not working properly in netcore project RRS feed

  • Question

  • Hi All,

    Currently I am trying to add the assembly references in netcoreapp project by using the below method. The below function working properly when we add the single assembly in the project. But I have faced the problem when I have tried to add the two or more assemblies one by one and this method is confused to add the next assemblies and my status bar message also not given the right content. I think the netcoreapp project has been tried to load after I have added the first assembly. 

    foreach (string assembly in _assemblies)
                        {
                            try
                            {
                                string assemblyName = assembly.Contains("\\") ? Path.GetFileName(assembly) : assembly.Split(',')[0];
                                string projectname = Project.Name;
                                if (!ExistingReferences.Contains(assemblyName.ToLower()))
                                {
                                    dte.StatusBar.Text = "VS Extensions: " + projectname + ", " + "Adding " + assemblyName + " assembly to the project reference...";
                                    vsProject.References.Add(assembly);
                                }
                            }
                            catch (Exception e)
                            {
    
                            }
                        }

    Could you please suggest me how can i resolve this issue? Also, is there any easy way to add the assembly reference in netcoreapp project by pro-grammatically ?

    Thanks,

    Ganesan R.

    Monday, February 18, 2019 12:18 PM

All replies

  • Hi Ganesan Rengasamy

    Welcome to the MSDN forum.

    Based on your description, it seems be related to asp.net core issue. Since our forum mainly focus on VS IDE. So far, I have contacted with the asp.net core engineer for ensure this issue association. you’d better redirect this issue to the asp.net core forum. and start a new thread to ask.

    Thank you for your understanding.

    Good luck.

    May


    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

    Tuesday, February 19, 2019 8:07 AM
  • Hi, 

    As you suggested I have asked the query in asp.net core forum. But they redirect me again to this forum 

    https://forums.asp.net/p/2153039/6252490.aspx?p=True&t=636868133155461232

    Could you please check and provide the solution asap. 

    Regards,

    Ganesan R. 

    Wednesday, February 27, 2019 5:30 AM
  • Hi Ganesan R,

    I will discuss with the VS extension team about this issue, if I get any latest information, I will share it to you in time.

    Appreciate your patience.

    Best Regards,

    Jack


    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, February 27, 2019 8:32 AM
    Moderator
  • @Ganesan R,

    Likely the automation layer didn’t handle project updates correctly. We need fix it, but it would still be slow to do DT build after adding every reference.  You could think about the CPS API, which would batch the entire operation.


    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 7, 2019 7:12 AM
    Moderator