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

Paket changes my config files #1248

Closed
haf opened this issue Nov 22, 2015 · 49 comments
Closed

Paket changes my config files #1248

haf opened this issue Nov 22, 2015 · 49 comments

Comments

@haf
Copy link
Member

haf commented Nov 22, 2015

screen shot 2015-11-22 at 10 38 05

Do you know why?

XML should not contain BOMs imo, as no other language really support them.

@forki
Copy link
Member

forki commented Nov 23, 2015

//cc @isaacabraham @mrinaldi

@isaacabraham
Copy link
Contributor

Urgh. Don't know why that's there. I think this should be done as part of the cleanup of the formatting of the BRs anyway (you can see from the </assemblyBinding></runtime> line that it's not formatted properly).

@konste
Copy link
Contributor

konste commented Dec 2, 2015

How about Paket leave XML formatting alone? We have never ending problem with Paket always changing our config files (incl. those it should not be touching at all). It keeps removing spaces in lines like 'value="false" />' So it removes the space between doublequote and slash and does it for ALL configs. We would leave it like that, but some other automated tool has different idea what the right spacing is and it keep adding that space back! This creates enormous churn and makes reviewing config file changes very hard. Please, please let Paket NOT CHANGE existing XML formatting. Especially considering we have "redirects: off" at the top of paket.dependencies.

@forki
Copy link
Member

forki commented Dec 2, 2015

Yes it's definitely the plan to keep formatting as stable as possible. Will
try to add couple of tests tomorrow
On Dec 2, 2015 21:36, "Konstantin Erman" [email protected] wrote:

How about Paket leave XML formatting alone? We have never ending problem
with Paket always changing our config files (incl. those it should not be
touching at all). It keeps removing spaces in lines like 'value="false" />'
So it removes the space between doublequote and slash and does it for ALL
configs. We would leave it like that, but some other automated tool has
different idea what the right spacing is and it keep adding that space
back! This creates enormous churn and makes reviewing config file changes
very hard. Please, please let Paket NOT CHANGE existing XML formatting.


Reply to this email directly or view it on GitHub
#1248 (comment).

@konste
Copy link
Contributor

konste commented Dec 2, 2015

@forki, thank you for speedy response! It is always great to work with you!

@forki
Copy link
Member

forki commented Dec 3, 2015

@konste can you give me the app.config in question (which contains value = false) for a unit test?

@konste
Copy link
Contributor

konste commented Dec 3, 2015

App.config.txt

@forki
Copy link
Member

forki commented Dec 3, 2015

wow. even if we disable formatting it seems .NET always writes value="false"/> as value="false" />

@konste
Copy link
Contributor

konste commented Dec 3, 2015

I may look into it. Which exactly .NET Xml facility is employed here? XmlDocument? XDocument?

But why rewrite configs which are not touched a bit at all?

@forki
Copy link
Member

forki commented Dec 3, 2015

that are two separate issues. one is we should not touched configs that we don't change logically. second is that we don't stuff outside of redirects

@konste
Copy link
Contributor

konste commented Dec 3, 2015

I understand that the second part is harder than it seems. Writing XML file is usually one call to a Save method (unless combination of reader and writer is used, which seems like overkill here), so we just need a way to preserve original formatting. So what .NET class is used to handle XML in Paket?

@konste
Copy link
Contributor

konste commented Dec 3, 2015

As far as I can tell from src\Paket.Core\BindingRedirects.fs XDocument is used. Then formatting preservation is as easy as calling Save like that: x.Save(writeFileName, SaveOptions.DisableFormatting);

@forki
Copy link
Member

forki commented Dec 3, 2015

^^ it's not I'm already doing this in my local version

@forki
Copy link
Member

forki commented Dec 3, 2015

@konste with latest changes we should not touch files when we don't do logical changes. can you please test it?

@konste
Copy link
Contributor

konste commented Dec 3, 2015

Is binary available? I don't have F# build environment at the moment.

@forki
Copy link
Member

forki commented Dec 3, 2015

Yes it's in latest release.
On Dec 3, 2015 19:41, "Konstantin Erman" [email protected] wrote:

Is binary available? I don't have F# build environment at the moment.


Reply to this email directly or view it on GitHub
#1248 (comment).

@konste
Copy link
Contributor

konste commented Dec 3, 2015

Version 2.32.5 keeps updating all config files when I do "paket update" which otherwise does nothing.

@forki
Copy link
Member

forki commented Dec 3, 2015

what's the diff?

@konste
Copy link
Contributor

konste commented Dec 3, 2015

Same - space before slash.

@forki
Copy link
Member

forki commented Dec 3, 2015

dog

@forki
Copy link
Member

forki commented Dec 3, 2015

nothing else? only the spaces?

@konste
Copy link
Contributor

konste commented Dec 3, 2015

  1. One space before EACH />
  2. At the end of each config a line is added:
 <runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" /></runtime>
  1. Fourth ".0" in versions is stripped again.

@forki
Copy link
Member

forki commented Dec 3, 2015

ah ok. I assume 3 is the reason.

since I didn't find a way to tel the .NET API to keep formatting of that char I tried to come up with "logical changes comparison". If no logical changes => we don't touch the file at all.

But 3 indicates a logical change => we touch it. please just commit that removement of .0 and the try again.

BTW: sorry. but this stuff is really tricky (and annoying)

@konste
Copy link
Contributor

konste commented Dec 3, 2015

-- If no logical changes => we don't touch the file at all.

Can we make it: no changes in BindingRedirect => we don't touch the file at all?

Because in our case we have "redirects: off" and I would expect it to cut short all attempts to even read config files.

@forki
Copy link
Member

forki commented Dec 3, 2015

yeah that's the next step.

".0" in versions is stripped again.

why is that even in there if you have redirects: off?

@konste
Copy link
Contributor

konste commented Dec 3, 2015

".0" in versions is stripped in paket.lock. Nothing to do with configs.

@forki
Copy link
Member

forki commented Dec 3, 2015

ok I'm confused now.

let's start over:

  • .0 is removed from lock file? That's intended and from other issue, right?
  • Nothing semantically changed in binding redirects file? Only reformatting?

@konste
Copy link
Contributor

konste commented Dec 3, 2015

Both Right.

@forki
Copy link
Member

forki commented Dec 3, 2015

is there a chance for me to reproduce? Can you mail me and tell me what you did? I won't make it public.

@konste
Copy link
Contributor

konste commented Dec 3, 2015

I think the problem is that last line it adds - it is basically empty BindingRedirects section. So the logic seems to be - if we are not going to add BindingRedirects to config, but it does not even have corresponding section - empty section is added. And "while we are here" extra spaces are added too.

@forki
Copy link
Member

forki commented Dec 3, 2015

ook just to confirm. can you commit that line and try again? does it stay stable and doesn't remove the space before the slashes?

@konste
Copy link
Contributor

konste commented Dec 3, 2015

Ok, here we go: when I replace this:

</configuration>

with this (literally!):

<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" /></runtime></configuration>

then Paket leaves that config alone and does not add extra spaces or change it in any other way.

But if I add this section formatted differently than all in one line, then it is ignored and config is reformatted. Weird.

@forki
Copy link
Member

forki commented Dec 3, 2015

GOOD!

that's what I wanted to hear - means we're on the right track. I will remove this tomorrow ;-)

@forki
Copy link
Member

forki commented Dec 3, 2015

And sorry for all the trouble...

@konste
Copy link
Contributor

konste commented Dec 3, 2015

No prob, thank you for the help! I wish I could contribute more than testing.

@forki
Copy link
Member

forki commented Dec 3, 2015

dude testing is most important since that guy is me:

wtf

@forki
Copy link
Member

forki commented Dec 4, 2015

@konste please retry agan. we now remove <runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" /></runtime>

@konste
Copy link
Contributor

konste commented Dec 4, 2015

2.32.7 is better and removing empty binding redirects section definitely works, but it is still not good enough. When config file does contain binding redirects section, then Paket still adds extra space! We have 17 files like that in solution. Still too much unnecessary churn.

@forki
Copy link
Member

forki commented Dec 4, 2015

don't really know how to fix that. yet
at least not with that .NET API

@forki
Copy link
Member

forki commented Dec 4, 2015

do you have bindind redirects completely disabled in paket? even for these 17 files?

@konste
Copy link
Contributor

konste commented Dec 4, 2015

If that is what "redirects: off" at the top of paket.dependencies does - then yes.

@forki
Copy link
Member

forki commented Dec 4, 2015

@mrinaldi can we skip the redirects processing completely in this case?

@mrinaldi
Copy link
Contributor

mrinaldi commented Dec 4, 2015

Yep, will do when I have the time.

@konste
Copy link
Contributor

konste commented Dec 4, 2015

For now I decided that space before slash is "standard enough" and I'm going to make all our configs look like that. Now Paket does not seem to change them anymore. One little concern though is that Paket still changes XML formatting as shown in the picture:
2015-12-04 12_03_20-start
But after I correct formatting manually Paket leaves it alone, which is good enough for all practical purposes. After all VS can reformat XML in one click.

Let's keep the issue open waiting for @mrinaldi to bypass config sniffing completely when possible.

@forki
Copy link
Member

forki commented Dec 9, 2015

Latest version should not do this anymore

@jackfoxy
Copy link

Yep, this is a problem for us too, add and update both are wiping out the binding redirects in our app.config files. (As of 24 hours ago using the latest from nuget. I see @forki 13 hours ago says the latest fixes this. If it changed within those 11 hours I have not tested.)

@forki
Copy link
Member

forki commented Dec 23, 2015

my comment was 13 days ago.
are you using redirect:force option?

@jackfoxy
Copy link

No, not using redirect or force. Here is the most common binding redirects Paket is overwriting. I can't remember why we need the FSharp.Core redirect, but we do need it. I think Paket wrote the <Paket>True</Paket> lines when I converted from nuget to paket. That may be the problem and why Paket thinks it can just eliminate these redirects.

<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.3.0.0" />
</dependentAssembly>

@forki
Copy link
Member

forki commented Dec 23, 2015

Use "nuget fsharp.core redirects:force" in your dependencies file. We
needed to change that default.
On Dec 23, 2015 7:35 PM, "Jack Fox" [email protected] wrote:

No, not using redirect or force. Here is the most common binding redirects
Paket is overwriting. I can't remember why we need the FSharp.Core
redirect, but we do need it. I think Paket wrote the True
lines when I converted from nuget to paket. That may be the problem and why
Paket thinks it can just eliminate these redirects.

True True


Reply to this email directly or view it on GitHub
#1248 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants