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

Need a working extension #2

Open
alexhass opened this issue Dec 18, 2020 · 12 comments
Open

Need a working extension #2

alexhass opened this issue Dec 18, 2020 · 12 comments

Comments

@alexhass
Copy link

I need to change JSON files in vscodium/vscode/azuredatastudio installations and other products I maintain. Therefore I need to alter product.json file. This extension seems to be able to do this task. I have seen it was committed first 3 years ago and one person is working on it...

How soon can I integrate this into my existing wix 3.x projects?

Are you planing to create a pull to wix toolset project to get this added?

@icnocop
Copy link

icnocop commented Dec 19, 2020

I'm not sure if this project will get natively integrated into the wix toolset project.

It shouldn't prevent you from using this extension though.

I'm using this in my wxs file without issues:

  1. Install the WiX Toolset v3.11 build tools.
  2. Get the latest code from https://github.com/icnocop/WixJsonExtension.
  3. Open WixJsonExtension.sln in Visual Studio 2017 and build using the Release configuration to generate WixJsonExtension.dll.
  4. Add xmlns:Json="http://schemas.nerdyduck.de/wix/JsonExtension" to the <Wix /> element in your wix file.
  5. Add <Json:JsonFile /> elements for the file you want to manipulate.
    For example:
<Component Id="ProductComponent" Guid="{51CDDB12-E903-436C-9371-2E4E93D3B109}">
    <File Id="JsonConfig" Source="appsettings.json"/>
    <Json:JsonFile Id="appSettingsPrice" File="[#JsonConfig]" ElementPath="$.store.book[\[]?(@.isbn == '0-553-21311-3')[\]].price" Value="1.67" />
    <Json:JsonFile Id="appSettingsCategory" File="[#JsonConfig]" ElementPath="$.store.book[\[]?(@.isbn == '0-553-21311-3')[\]].category" Value="[MY_VALUE]" />
</Component>
  1. Add WixJsonExtension.dll as an extension to your wix project file.

A sample WiX project can be found here: https://github.com/NerdyDuck/WixJsonExtension/tree/46023d86c81d2a21cd44c479fd2da0e69a1fee5e/TestJsonConfigInstaller

@alexhass
Copy link
Author

How can I do not if I do not have a Visual Studio 2017?

@icnocop
Copy link

icnocop commented Dec 22, 2020

You can download Visual Studio 2017 here.

@alexhass
Copy link
Author

Any chance this can be precompiled in the project? So I can drop the DLL into the Wix Folder and can use it?

@mgphall
Copy link

mgphall commented Jan 29, 2021

does not compile on visual Studio 2017 15.9.27
Severity Code Description Project File Line Suppression State
Error The system cannot find the file 'jsonca.dll' with type 'Binary'. JsonExtension Documents\WixJsonExtension-46023d86c81d2a21cd44c479fd2da0e69a1fee5e\src\wixlib\Library.wxs 11

@mgphall
Copy link

mgphall commented Jan 29, 2021

precompiled dll would be nice :-)

@icnocop
Copy link

icnocop commented Sep 13, 2021

For fixes to the code, please see pull request #1 which is from a fork of this repo.

@impojr
Copy link

impojr commented Dec 21, 2021

@icnocop (sorry for the very late tag, I have been stuck on this for days now)

Should the pull request work just as is? I can get it to compile but the appsettings.json file it installs does not change any values (I have the same product.wxs as the sample project). I am wondering if there is something I need to do to get this to work as expected

@icnocop
Copy link

icnocop commented May 15, 2022

@impojr I recommend creating a verbose MSI log as it may contain detailed information about the reason why you're experiencing the unexpected behavior.

@seidhkona
Copy link

seidhkona commented Sep 23, 2022

I know this is old and looks like there have been no updates recently, I'm having the same issue. Project builds and I see output in verbose log after the install, but no values are changed.
Action start 15:26:05: JsonFile.
MSI (s) (78:B8) [15:26:05:391]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSIB6E1.tmp, Entrypoint: JsonFile
MSI (s) (78:C4) [15:26:05:393]: Generating random cookie.
MSI (s) (78:C4) [15:26:05:403]: Created Custom Action Server with PID 3772 (0xEBC).
MSI (s) (78:48) [15:26:05:523]: Running as a service.
MSI (s) (78:48) [15:26:05:529]: Hello, I'm your 32bit Impersonated custom action server.
JsonFile: Entered JsonFile CA
JsonFile: Created PMSIHANDLE hView
JsonFile: Created PMSIHANDLE hRec
JsonFile: MSIHANDLE's created for JsonFile CA
JsonFile: Getting JsonFile Id.
JsonFile: Getting JsonFile File for Id:descriptionTest
JsonFile: Getting JsonFile ElementPath for Id:descriptionTest
JsonFile: Getting JsonFile VerifyPath for Id:descriptionTest
JsonFile: Getting JsonFile Value for Id:descriptionTest
JsonFile: Getting JsonFile Flags for Id:descriptionTest
JsonFile: Getting JsonFile Component for Id:descriptionTest
JsonFile: Updating JsonFile for Id:descriptionTest
JsonFile: Created wifstream, C:\Program Files (x86)\MyTestApp\test.json
JsonFile: Using the following flags, 2, true
JsonFile: Found ElementPath as $.description
JsonFile: Updated ElementPath to $.description
JsonFile: About to replace value: |$.description| {TEST}
JsonFile: Updating the json $.description with values TEST.
JsonFile: created output stream
JsonFile: dumped output stream
JsonFile: closed output stream
JsonFile: Closed PMSIHANDLE hView
Action ended 15:26:05: JsonFile. Return value 1.
Action ended 15:26:05: INSTALL. Return value 1.

@icnocop
Copy link

icnocop commented Sep 24, 2022

I'm not sure why your JSON file is not being updated.

Are the values displayed in the msi log file expected?

Can you log the results to the msi log file?

For example, I don't see anything logged after the last "Updating..." message.
Should I expect to see a message like "Updated..."?
Otherwise, I recommend adding additional log messages like "Updated..." or "Finished..." for example to verify the code got further.
The custom action may have exited before being able to complete the operation.

Is the file read-only?
Does the json file have the correct syntax?

Are you able to attach the debugger to the msiexec process to debug the custom action?
Otherwise, you can also try to output more information to the logs and check return values for any errors.

There's another fork of this project which seems to disable WOW64 redirection if that could be the issue in your case:
https://github.com/air2/WixJsonExtension

Have you validated the JSON path works in another application or using different code?

@seidhkona
Copy link

I tried this with included Test Project as well, it didn't update the json there either. It's possible that dll didn't get compiled correctly (I built it with VS2019). I don't work in Visual Studio, so had to install it only for compiling the dll, which is unfortunate. Having precompiled working dll would be very nice. Will try your suggestion to use a forked project addressing WOW64 redirection next.

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

5 participants