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

  • Thread starter Thread starter Ganesan Rengasamy
  • Start date Start date
G

Ganesan Rengasamy

Guest
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.

Continue reading...
 
Back
Top