private static async Task <HashSet <string> > GetWebsiteLocalAssembliesAsync(EnvDTE.Project envDTEProject) { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var assemblies = new HashSet <string>(PathComparer.Default); var references = GetAssemblyReferences(envDTEProject); foreach (AssemblyReference reference in references) { // For websites only include bin assemblies if (reference.ReferencedProject == null && reference.ReferenceKind == AssemblyReferenceType.AssemblyReferenceBin && File.Exists(reference.FullPath)) { assemblies.Add(reference.FullPath); } } // For website projects, we always add .refresh files that point to the corresponding binaries in packages. In the event of bin deployed assemblies that are also GACed, // the ReferenceKind is not AssemblyReferenceBin. Consequently, we work around this by looking for any additional assembly declarations specified via .refresh files. var envDTEProjectPath = await envDTEProject.GetFullPathAsync(); CollectionsUtility.AddRange(assemblies, RefreshFileUtility.ResolveRefreshPaths(envDTEProjectPath)); return(assemblies); }
public override void AddReference(string referencePath) { string name = Path.GetFileNameWithoutExtension(referencePath); try { var root = EnvDTEProjectUtility.GetFullPath(EnvDTEProject); EnvDTEProjectUtility.GetAssemblyReferences(EnvDTEProject).AddFromFile(PathUtility.GetAbsolutePath(root, referencePath)); // Always create a refresh file. Vs does this for us in most cases, however for GACed binaries, it resorts to adding a web.config entry instead. // This may result in deployment issues. To work around ths, we'll always attempt to add a file to the bin. RefreshFileUtility.CreateRefreshFile(root, PathUtility.GetAbsolutePath(EnvDTEProjectUtility.GetFullPath(EnvDTEProject), referencePath), this); NuGetProjectContext.Log(MessageLevel.Debug, Strings.Debug_AddReference, name, ProjectName); } catch (Exception e) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Strings.FailedToAddReference, name), e); } }
public override async Task AddReferenceAsync(string referencePath) { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var name = Path.GetFileNameWithoutExtension(referencePath); try { EnvDTEProjectUtility.GetAssemblyReferences(VsProjectAdapter.Project).AddFromFile(PathUtility.GetAbsolutePath(ProjectFullPath, referencePath)); // Always create a refresh file. Vs does this for us in most cases, however for GACed binaries, it resorts to adding a web.config entry instead. // This may result in deployment issues. To work around ths, we'll always attempt to add a file to the bin. RefreshFileUtility.CreateRefreshFile(ProjectFullPath, PathUtility.GetAbsolutePath(ProjectFullPath, referencePath), this); NuGetProjectContext.Log(ProjectManagement.MessageLevel.Debug, $"Added reference '{name}' to project:'{ProjectName}' "); } catch (Exception e) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Strings.FailedToAddReference, name), e); } }