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

XDT transform causes xml file to have extra data in it (unusable until manually fixed) #1482

Closed
bcurran3 opened this issue Feb 3, 2018 · 2 comments

Comments

@bcurran3
Copy link

bcurran3 commented Feb 3, 2018

Moving bug report to correct area (cross post).
Originally from: chocolatey-community/simple-server#19

Error occurs during install of Chocolatey Server (Simple)

It looks like a bug in Chocolatey actually - a double transform, where the first corrupts the file and the second can't make changes:

Preparing transform for 'C:\ProgramData\chocolatey\lib\chocolatey.server\tools\chocolatey.server\Web.config.install.xdt'
Transforming 'Web.config' with the data from 'Web.config.install.xdt'
Transform applied successfully for 'C:\ProgramData\chocolatey\lib\chocolatey.server\tools\chocolatey.server\Web.config'

Preparing transform for 'C:\ProgramData\chocolatey\lib\chocolatey.server\tools\chocolatey.server\bin\Web.config.install.xdt'
Transforming 'Web.config' with the data from 'Web.config.install.xdt'
[ERROR] - Error transforming config file:
Data at the root level is invalid. Line 230, position 17.

@ferventcoder
Copy link
Member

ferventcoder commented Feb 4, 2018

Thank you for logging this. Let's rewrite this a bit. Happens with all XDT Transforms.

XDT transformation was introduced in #331 (Chocolatey v0.9.9.7) but hasn't seen wide use (needs more documentation). There is a bug in it that happens sometimes that we've noticed where it adds extra data to the end of the file. It looks like (as you pointed out) it is going through the transform twice. So we'll need to investigate and hopefully find a solution.

@ferventcoder ferventcoder changed the title BUG: double transform occurs during install of Chocolatey Server (Simple) XDT transform causes xml file to have extra data in it (unusable until manually fixed) Feb 4, 2018
@ferventcoder ferventcoder added this to the 0.10.9 milestone Feb 4, 2018
gep13 added a commit to gep13/choco that referenced this issue Feb 19, 2018
- Use Mutex to ensure that file is only used for each transformation
- Verify by loading transformed file that it contains valid XML
- Restore backup file in the event of an error
gep13 added a commit to gep13/choco that referenced this issue Feb 19, 2018
- Use Mutex to ensure that file is only used for each transformation
- Verify by loading transformed file that it contains valid XML
- Restore backup file in the event of an error
gep13 added a commit to gep13/choco that referenced this issue Feb 20, 2018
- Use Mutex to ensure that file is only used for each transformation
- Verify by loading transformed file that it contains valid XML
- Restore backup file in the event of an error
ferventcoder added a commit that referenced this issue Feb 20, 2018
(GH-1482) Improve handling of XDT Transform errors
@ferventcoder
Copy link
Member

Merged into stable at 4f5b965

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

No branches or pull requests

3 participants