Is there an easy way to move vckpg to new "identical" machine? - migrate

I've got two "identical" (same OS, Visual Studio, etc.) machines. One has vcpkg with a number of installed packages ('older' versions), and I'd like an identical copy on the new machine that is integrated with Visual Studio. There seem to be a number of relatively complicated methods of accomplishing this: export/import, manifest versioning and binary caching. But what I'd really like to do is run a command on the new machine like "vcpkg installfrompath " or copy the vcpkg folder to the new machine and run "vcpkg restore". I really feel like this must exist and I'm just not seeing it.

Got answer from MS :) https://github.com/microsoft/vcpkg/issues/23464
Simply copy the vcpkg folder and run "vcpkg integrate install"
I verified that this works. Interestingly, this is the command you use when initially setting up vcpkg, but it didn't click for me, not did I see this answer in any of the similar questions I saw posted.

Use manifest mode. It's really easy and gives you exact control over different versions. Just add a file called "vcpkg.json" to the root folder of your project, activate "manifest" in the vcpkg entry of your Visual Studio project and you are almost done.
This is what a manifest file looks like:
{
"name": "myapp",
"version": "1.66.0",
"dependencies": [
{ "name": "pybind11" },
{ "name": "boost-format" },
{ "name": "boost-preprocessor" },
{ "name": "boost-uuid" },
{
"name": "python3",
"version>=": "3.7.4"
}
],
"builtin-baseline": "03ca9b59af1506a86840e3a3a01a092f3333a29b",
"homepage": "https://some.server.loc",
"supports": "windows"
}
Then simply build with Visual Studio. This will invoke vcpkg and build the exact versions you want.

Related

VS Code in docker container: Is there a way to automatically install extensions when connecting to a running container?

When I use the "Attach to Running Container..." feature of VS Code I have to manually install the few extensions that I need installed in the container.
Is there a way to setup VS Code such that when I attach to a running container it automatically installs the extensions I need?
I am aware of this question: Automatically install extensions in VS Code?
But that doesn't say anything about installing extensions in running containers automatically and isn't clear on how the answers could be used to accomplish this.
The specific extension I need installed is the Python extension from Microsoft. I'm not sure that is relevant, but just in case it is.
From a similar question on Github:
You can add an array of extension ids to the 'attach' configuration ("extensions" property). Use F1 > Remote-Containers: Open Attached Container Configuration File... to open that. Note that for each container extensions will be installed only the first time you attach to it, changes to "extensions" in the config file after that will only apply to the next container with the same image name (or container name, if the config is scoped to that).
Not sure when this feature was added, but in VSCode, open your project in the remote container as normal, then under the extensions side-tab, find the extension you want and click the "cog" settings icon. It has the open to "Add to devcontainer.json".
This command will add that extension to the customizations.vscode.extensions setting in the devcontainer.json file.
{
"name": "MyContainer",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"customizations": {
"vscode": {
"extensions": [
# added by VSCode
"ms-python.python"
]
}
},
...

Is there a way to build different projects (different electron-builder file) for electron

We have a white-labeled app built with electron+angular and we want to build 3 different let's say 'flavours' of the app. Except for the UI changes in Angular we have a different electron-builder file with configurations for each project. The problem is that after I build the first one the next one is twice its size (as a .exe) and when I build the third one it's even bigger. It does not matter which I build first, as this is always the case.
I am building these apps with the electron-builder build command, using the --config option to pass a file with configurations.
This is the electron-builder file that I am using (with PROJECT_NAME, PROJECT_APP_ID, and PROJECT_ID changing depending on the project).
"productName": "<PROJECT_NAME>",
"appId": "<PROJECT_APP_ID>",
"directories": {
"output": "release/<PROJECT_ID>"
},
"files": [
"**/*",
"!**/*.ts",
"!*.code-workspace",
"!LICENSE.md",
"!package.json",
"!package-lock.json",
"!src/",
"!e2e/",
"!hooks/",
"!angular.json",
"!_config.yml",
"!karma.conf.js",
"!tsconfig.json",
"!tslint.json"
],
"win": {
"icon": "dist/assets/icons/<PROJECT_ID>"
},
"mac": {
"icon": "dist/assets/icons/<PROJECT_ID>"
},
"linux": {
"icon": "dist/assets/icons/<PROJECT_ID>"
},
}
Am I missing something for electron-builder? I am thinking maybe it keeps a 'cache' or something in a temporary folder and uses that to build on.
I know the question is a bit over the place, but I don't have experience with electron-builder. Any help or suggestion is welcomed.
Some details:
I tried building it from both a windows machine and mac os.
I am using electron-builder v22.9.1
I have tried using different folders for the result, it still didn't work.
[UPDATE] In the script that i use to build these projects, if i delete the directory of the build and then continue with the others, it will work.

Electron builder and asset files

I have an issue building for distribution an electron app, on macOS.
I have some folders that are in the root dir of my project, next to my index.js, which I need to be included in my packaged app.
After trying by hardcoding each and every file inside of package.json, which didn't help, I ended up with the following block
"extraResources": [
{
"from": "files/",
"to": "files/",
"filter": [
"**/*"
]
},
{
"from": "assets/",
"to": "assets/",
"filter": [
"**/*"
]
},
{
"from": "accounts/",
"to": "accounts/",
"filter": [
"**/*"
]
}
]
If I run the .app it appears that the files are not there. Opening the Contents/Resources, I see they are there, so, toying around I discovered that the app is looking inside the app.asar container, where obviously the files are not.
I found a small hack by adding a couple of '..' in front of all my paths, so it goes outside the app.asar container but I really think this is a bit idiotic to be the solution to my issue.
Plus, I plan to build this for multiple platforms and I have a feeling that if I go through with this hacky way of fixing it, I'll have to create a hack for each platform, which I'd rather not do...
if you have files that you are using in the html (in my example assets/css etc.), or requiring in any file and have a folder structure like this, the folders would be automaticly in the asar.
Note: asar is read only package, you cant add, remove or edit files after creating this file.
the using of the css files in the assets/css folder is simple:
use the relative path from your html file and it would work on all plattforms.
if you have files that are not related to your project, or not used in your project but should be available in the packaged app:
you must use "extraFiles" in your package.json
extraFiles would copy the files to the app content directory on Mac OS, on Windows and Linux it will copy it to the app root directory. If you use extraResources it will copy the files to Contents/Resources on Mac and on Windows it will copy the files to resources Folder.
"extraFiles": [
"files",
"assets",
"accounts"
]
note: empty folders would not be copied
in your app use something like this module to get the root path of your app, and use your files with this path
alternative: use process.execPath and replace your executable name to get the correct path
based on your comment:
if you must load this files (css/js) in your app html, you can load dynamicly on the onload event with the solution i provided you above.

exiftool-vendored doesn't return when used in an electron app on Mac?

On Mac, when I run my app from WebStorm, exiftool-vendored works great. However, when I build my app (I use electron-builder) and install it on the same Mac, it never returns, even just trying to get the version:
exiftool.version().then(version => writeBreadcrumb('exif', version))
In other words, no error is raised, and the then is never executed when running an installed version of my app, though it works fine running my app from WebStorm (with cd build && electron .)
What am I doing wrong? Is there an example anywhere of how to use exiftool-vendored in an electron app?
You should take a look at what the docs say about making it work with Electron:
How do you make this work with electron?
Electron is notoriously brittle and buggy, and is not officially supported by this package. Although PhotoStructure uses this package within electron, there's a nontrivial amount of auxiliary support code specific to that project to make it work smoothly.
If you're still anxious to try, here are some things to keep in mind:
Note that this package will spawn exiftool external processes, which means the exiftool-vendored.pl and exiftool-vendored.exe packages should be included in your asarUnpack. SmartUnpack might work, but if it doesn't use a pattern like node_modules/{exiftool-vendored.*}/**/*.
If you're requiring exiftool-vendored from within a webview, you're gonna have a bad time. Many things won't work due to a lack of node compatibility within electron.
__dirname at runtime from within an asar package after webpacking will be invalid, so don't rely on that.
— https://github.com/photostructure/exiftool-vendored.js/wiki/FAQ#how-do-you-make-this-work-with-electron
Since I never found a way to get exiftool-vendored to work with electron on Mac, I accepted the above answer, as essentially a warning to steer clear of exiftool-vendored for electron on Mac.
This answer is included for completeness, for those of us who need exiftool in an electron app for both Mac and Windows:
I used node-exiftool with these settings added in package.json for electron-builder:
"build": {
...
"win": {
...
"extraResources": "exiftoolwin/**/*"
},
"mac": {
...
"extraResources": "exiftool/**/*"
}
}
In the root of my project, I added folders exiftoolwin and exiftool. In exiftoolwin, I put exiftool.exe which I obtained by following the Windows Stand-Alone Executable instructions here, and in my exiftool folder I put exiftool and lib which I obtained by extracting the full perl distribution on Mac, as described on the same page.
Then, in my .jsx (I'm using React):
import exiftool from 'node-exiftool';
const exiftoolFolderAndFile = process.platform === 'win32' ? 'exiftoolwin/exiftool.exe' : 'exiftool/exiftool';
const exiftoolPath = path.resolve(__dirname, '../..', exiftoolFolderAndFile);
const ep = new exiftool.ExiftoolProcess(exiftoolPath);
Then I just use ep as described here.
This is working for us:
add this dependency:
"exiftool-vendored": "^15.2.0",
Update package.json "build" section for mac ( not needed for windows as far as we can see )
"build": {
"mac": {
...
"asarUnpack": [
"node_modules/exiftool-vendored/**" ,
"node_modules/exiftool-vendored.pl/**"
]
}
}

bower install take repo, not specific files in main

I am trying to install some js files via bower. My repo has a bower.json with a main property, however the whole repo gets installed to components/, not just the files in the dist/custom/ dir.
Here is what my bower.rc looks like
{
"name": "jquery-m",
"version": "2.0.2mup",
"description": "Meetup custom build of jQuery 2.0, used on mobile",
"main": [ "./dist/custom/" ],
"license": "MIT"
}
Is this the way bower is supposed to work? I thought it was possible just to specify certain files with your main property.
Yes, this is how Bower is meant to work. Bower-installer looks like a more lightweight solution than Grunt to solve the exact requirement you're describing and get just the files you need to be deployed to production.
Yes, that's how Bower works.
It always look for the matching tag on the repo; if cannot find one, it goes with the default branch, and download it.
The unique usage I've seen so far for the main property of a bower.json file is for integration, for example with build tools, like Grunt (there are lots of other bower related tasks, just Google around) and others.
This is a common misconception.
As stated in Bower documentation, the main property is a string/array listing the primary endpoints of your package.
Bower package maintainers (and maybe users, using the overrides property) can use the ignore property, which is an array of paths not needed in production that you want Bower to ignore when installing your package.
Example:
{
"name": "stackoverflow",
"version": "1.0.0",
"ignore": [
"test/**",
".jshintrc"
],
"dependencies": {
"foo": "~1.1"
}
}

Resources