Windows Universal App "rebranding": one app but multiple packages - windows-phone

I developped a Universal App for Windows 8.1/Windows Phone 8.1.
This application must be proposed by default to the main customers, but other clients must be able to customize it by giving their own name, their own assets (icons, splashscreen, ...) and their own UI colors. I look for a solution allowing me to do this.
I thus thought to create multiple files "appxmanifest":
the default one "Package.appxmanifest"
and one per customer "Customer1.appxmanifest", "Customer2.appxmanifest", ...
=> But I don't know how to specify a different "appxmanifest" to use at compilation: is it possible?
In addition, the UI colors are defined in a xaml file, which is merged with the "App.xaml" file using "MergedDictionaries".
=> Is there a way to do this?

You can do this with the combination of a build configuration and a pre-build event.
Create a build configuration for each customer, with their name
Create a prebuild.bat file in your project directory that will copy the files for the correct customer to the project directory.
#setlocal enableextensions enabledelayedexpansion
#echo off
set buildconfig=%1
set projectdir=%~2
if %buildconfig% == "Customer1" goto CopyCustomerFiles
if %buildconfig% == "Customer2" goto CopyCustomerFiles
goto End
:CopyCustomerFiles
xcopy "%projectdir%\customers\%buildconfig%" "%projectdir%" /I/Y/R/S
goto End
:End
endlocal
Add a pre-build event like so:
"$(ProjectDir)prebuild.bat" "$(ConfigurationName)" "$(ProjectDir)"
The batch file will copy the entire contents of the customer specific folder into your project, which can include the appxmanifest and xaml files.
This assumes that all customer specific files are located in the folder customers/[name of customer] of the Windows Phone project.

Related

How to check in AppleScript if a MacOS App is Universal or not?

I need to take a couple decisions in my project based on whether a certain App on MacOS is Universal (x86_64 arm64) or Intel (x86_64). I understand that there are ways to run shell script using AppleScript on Mac and so, essentially, what I am looking for is a command which can return whether an App is Universal or not. I believe the command would need to take the App's executable binary's location as input, which the project is already aware of.
Please note that I can only run AppleScript in my project because of limitations in VBA. If it's possible to run a shell script directly from VBA on a macos, that solution would be more than welcome.
PS: I am very new to VBA on mac, so please understand if this sounds like a silly question.
The file shell utility can determine the file type, which for the application executable will include the architectures. Note that older "universal" binaries include an i386 (or even ppc) architecture, so a check should be made to see if the architectures contain arm64.
The following handler will return the architecture types of an application (remove the statement getting the executable as needed), with an option to return a boolean if it is a universal application:
use framework "Foundation" -- for NSBundle
use scripting additions
return architectures for (choose file of type "com.apple.application-bundle") -- with isUniversal
on architectures for appPath given isUniversal:isUniversal : false -- given argument is optional
set appPath to POSIX path of appPath
set appPath to (current application's NSBundle's bundleWithPath:(appPath))'s executableURL's |path| as text
set archTypes to paragraphs of (do shell script "/usr/bin/file -bh " & quoted form of appPath)
set arm to false
set archList to {}
if (count archTypes) > 1 then -- multiple architectures
repeat with anItem in rest of archTypes
set anArch to last word of anItem
if anArch contains "arm64" then set arm to true -- for newer universal apps
if anArch is not in archList then set end of archList to anArch
end repeat
else -- single architecture
set end of archList to last word of (archTypes as text)
end if
if isUniversal is true then return ((first item of archTypes contains "universal") and arm)
return archList
end architectures

Find all users, use them as variable to pull appdata directory list from cmd?

I'm trying to build out a script that will pull the list of users, grab each of their names and then do a directory list for each of their appdata folders.
So far I'm thinking that I could just use the net user > C:\userlist.txt to create the list of users, my real problem comes in grabbing the user's names and putting them into the next command.
By using a variable of some kind I would like to have findstr pull in each user so that I could get a list of all the users's directories.
The end result would look something like this:
dir C:\users\$variableforusers\AppData\Roaming > C:\directorylist.txt
I'd like to be able to get this command to run for each users appdata directory, so this command would need to repeat itself based on how many users the end machine has.
This will be running from the local system account so %appdata% will not work as it only gives you the currently logged in user's appdata folder.
If possible, I'd like for the directory list to all be dumped into one file, otherwise I'd have to introduce a variable to check multiple files for the results.
Thanks ahead of time for the help guys!
I think you should not use user's name to obtain a path to user's profile directory. The directory name can be different than user's name - for example in case user name hsa been changed after the profile was created or if there is a user name conflict (a local user has the same username as a domain user).
You can do a dir of AppData\Roaming for each subdirectory of C:\Users using the following syntax:
for /d %A in (C:\Users\*) do if exist %A\AppData\Roaming dir %A\AppData\Roaming
But again this solution will omit any user profiles that are stored outside C:\Users.
To do a dir of AppData\Roaming directory of each user profile, you can get the paths of user profiles from registry:
for /f "tokens=3" %A in ('reg query "HKLM\Software\Microsoft\WindowsN T\CurrentVersion\ProfileList" /s /v ProfileImagePath ^| find "REG_EXPAND_SZ"') do #dir %A\AppData\Roaming
If you want to use these commands in a script, use double percent signs (%%A).
To learn more about for command type for /?

Why won't MSBuild build a project with a dot in the name?

The Story So Far
I've got a nice solution with a desktop application project, a few library projects, and a couple of development tools projects (also desktop applications). At the moment, my build server outputs all of the code into one OutputPath. So we end up with
drop-x.y.z\
Company.MainApplication.exe <-- main application
Company.MainApplicationCore.dll <-- libraries
Helper.exe <-- developer tools
Grapher.exe
Parser.exe
... <-- the rest of the output
But, we're growing up and people outside of our team want access to our tools. So I want to organize the output. I decided that what we would want is a different OutputPath per executable project
drop-x.y.z\
Company.MainApplication\
Company.MainApplication.exe <-- main application
Company.MainApplicationCore.dll <-- libraries
... <-- application specific output
Helper\
Helper.exe <-- developer tools
... <-- tool specific output
Grapher\
Grapher.exe
...
Parser\
Parser.exe
...
What I Did
I found this simple command. I like it because it retains all the Solution working-dir context that makes msbuild a pain.
msbuild /target:<ProjectName>
For example, from my solution root as a working directory, I would call
PS> msbuild /target:Helper /property:OutputPath="$pwd\out\Helper"
I'm testing this from PowerShell, so that $pwd resolves to the full path to my working directory, or the Solution root in this case. I get the output I desire.
However, when I run this command
PS> msbuild /target:Company.MainApplication /property:OutputPath="$pwd\out\Company.MainApplication"
I get the following error output (there's no more information, I ran with /verbosity:diagnostic)
The target "Company.MainApplication" does not exist in the project.
What I Need
The command fails on any project with a dot or dots in the name. I tried with many combinations of working directories and properties. I tried several ways of escaping the property values. I also tried running the command from a <Task> in a targets file.
I need to know either
A) How to fix this command to work property
B) How to achieve the same output with minimal friction
Try using an underscore as an escape character for the dot in the target parameter, e.g.
msbuild /target:Company_MainApplication /property:OutputPath="$pwd\out\Company.MainApplication"
Specify the target after the -target: switch in the format :. If the project name contains any of the characters %, $, #, ;, ., (, ), or ', replace them with an _ in the specified target name.
https://learn.microsoft.com/en-us/visualstudio/msbuild/how-to-build-specific-targets-in-solutions-by-using-msbuild-exe?view=vs-2019
Dan Nolan's answer and comments are correct. Just want to supplement the Microsoft documentation.
The /targets: switch is to identify a <Target to run in the project file. You need to supply your .csproj file as a an argument that is not prefixed by a /xx option marker.
You might also want to work based on the .sln file. In that case, you still dont specify the project in the .sln to build in this manner. I'll leave you to search up the correct syntax in case that's what you end up doing.

.tex files not found when placed in a folder declared in TEXINPUTS

I have a set of documents based on a LaTeX template. Every document has its own folder, as following:
docs-folder
|-doc #1
|-doc #2
...
|-doc #n
|-texmf
|-tex
|-bibtex
|-fonts
|-docs
|-misc
|-logo.jpg
|-acronyms.tex
I wrote the template on my own, and, for every document (from #1 to #n) it loads the files logo.jpg and acronyms.tex with \includegraphics{logo.jpg} and \input{acronyms.tex}.
The path ..\docs-folder\texmf is set as a project root in MikTeX, and the local texmf tree is recognized properly, excluding the misc folder.
So, the path ..\docs-folder\texmf\misc is set as the value of the TEXINPUTS environment variable (under Windows). This is done in order to avoid an unwanted replication of the two files.
What happens is that, when I compile one of the documents, the file acronyms.tex is not found, while the logo.jpg is correctly found by PDFLaTeX.
I have no wonder why the acronyms.tex file is not loaded.
On unix systems the solution is to run texhash or mktexlsr. According to this page, the equivalent solution for MikTeX is to run MikTeX settings and click the "Refresh FNDB" button.

compile multiple dlls

I have to compile multiple dlls (around 100) for my project.
Each project/build will have only one source code file different.
These dlls should have an index included. Like calc0023.dll
What is the easiest way to do that?
a .cmd script :
for %%f in (*.cs) do (
csc.exe /target:dll /o:outdir\%%~nf.dll %%f CommonFile.cs
)
If all the source files are in the same directory, you would have to exclude the common file from the loop.
for %%f in (*.cs) do (
if not %%f==CommonFile.cs (
csc.exe /target:dll /o:outdir\%%~nf.dll %%f CommonFile.cs
)
)
The previous scripts name the generated DLL with the name of the unique source file. If you want to use a numeric index for the filename, then you need to introduce another variable.
setlocal enabledelayedexpansion
set count=1
for %%f in ("*.cs") do (
if not %%f==CommonFile.cs (
set CSTR=00!COUNT!
set OUTFILE=Calc!CSTR:~-3!
csc.exe /target:dll /o:outdir\!OUTFILE!.dll %%f CommonFile.cs
set /a COUNT=!COUNT!+1
)
)
endlocal
Whatever version of (visual studio??) you're using, I would definitely kick these off on the command line. The simplest possible thing that would work:
Write a script that calls each projects project / solution file using devenv.
See the msdn page on how to build using the command line.
If you have so much code repetition in each dll, here is what i suggest, take the code common to all DLLs and create a DLL of that code/functions. And then create rest of the DLLs which internally call the main DLL. But to have features like particular naming and order of build you would need to write the batch file. Visual studio in project options display the various commandline parameters which can assit you in building the projects.
But i dont know what particular requirement you going to address by creating so many DLLs which will make it difficult for you to manage the DLLs itself. One benefit i see if you create a common DLL with the repetive code is: If you change anything in the main code, you just need to recompile one project instead of 100 projects instead where you would have compiled 100 projects.