Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix https://github.com/NuGet/Home/issues/1550 #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private void Save(string configFileFullPath, XDocument document)
memoryStream.Seek(0, SeekOrigin.Begin);

// MSBuildNuGetProjectSystem.AddFile() can't handle full path if the app.config
// file does not exist in the project yet. This happens when NuGet first creates
// file does not exist in the project yet. This happens when NuGet first creates
// app.config in the project directory. In this case, only the file name is passed.
var path = configFileFullPath;
var defaultConfigFile = Path.Combine(
Expand All @@ -225,11 +225,11 @@ private static ILookup<AssemblyBinding, XElement> GetAssemblyBindings(XDocument

// We're going to need to know which element is associated with what binding for removal
var assemblyElementPairs = from dependentAssemblyElement in assemblyBindingElements
select new
{
Binding = AssemblyBinding.Parse(dependentAssemblyElement),
Element = dependentAssemblyElement
};
select new
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just the result of auto formatting the document

{
Binding = AssemblyBinding.Parse(dependentAssemblyElement),
Element = dependentAssemblyElement
};

// Return a mapping from binding to element
return assemblyElementPairs.ToLookup(p => p.Binding, p => p.Element);
Expand All @@ -243,11 +243,22 @@ private static IEnumerable<XElement> GetAssemblyBindingElements(XElement runtime

private XDocument GetConfiguration(string configFileFullPath)
{
return ProjectManagement.XmlUtility.GetOrCreateDocument(
"configuration",
Path.GetDirectoryName(configFileFullPath),
Path.GetFileName(configFileFullPath),
MSBuildNuGetProjectSystem.NuGetProjectContext);
try
{
return ProjectManagement.XmlUtility.GetOrCreateDocument(
"configuration",
Path.GetDirectoryName(configFileFullPath),
Path.GetFileName(configFileFullPath),
MSBuildNuGetProjectSystem.NuGetProjectContext);
}
catch (Exception ex)
{
var errorMessage = string.Format(Strings.Error_WhileLoadingConfigForBindingRedirects,
configFileFullPath,
ex.Message);

throw new InvalidOperationException(errorMessage, ex);
}
}

private static void UpdateBindingRedirectElement(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,7 @@
<data name="SolutionIsNotSaved" xml:space="preserve">
<value>Solution is not saved. Please save your solution before managing NuGet packages.</value>
</data>
<data name="Error_WhileLoadingConfigForBindingRedirects" xml:space="preserve">
<value>Failed to load '{0}', while updating binding redirects. {1}</value>
</data>
</root>