Swift Package Plugin - Copy Build Artifact - swift-package-manager

Is it possible to create a build tool plugin that runs after the build and copies build artifacts to another location in the package directory?
For example, say I have an executable target named tool. Each time that I build tool, I'd like to copy the build artifact from .build/release/tool to ./tool so that it's available at the root of the package.
As far as I can tell, this can't be done. But I may be missing something.
(Crosspost: https://forums.swift.org/t/swift-package-plugin-copy-build-artifact/60765)

Related

dotnet build ZIP package - remove lengthy folder structure

I'm trying to create a ZIP package of my Azure Function so I can upload each build to a storage account and reference them directly via an app setting instead of performing actual deployments.
In Azure DevOps pipelines, I'm using dotnet build (and tried locally as well) with the following args:
dotnet build Solution.sln /nologo /p:PublishProfile=Release /p:configuration="Release" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)" /p:SkipInvalidConfigurations=true
It works pretty fine and creates ZIP packages of each project that I need to deploy. However, looking inside each ZIP file, it essentially has some parameter and info XML files and a long folder structure where the actual function resides:
FunctionName.zip\Content\C_C\Projects\ProjectName\Main\FunctionName\obj\Release\netcoreapp3.1\PubTmp\Out
I understand that the command is creating a deployment package, hence a bunch of XML files which could be useful for parameter substitutions or transformations.
But I just actually want a ZIP file of everything that resides within that Out folder. Is there any parameter I am missing?
I've checked dotnet publish and haven't been able to create a proper ZIP package on it, seems like you need to zip it up manually.

AssemblyInfo ingrored when building from GitLab-Runner

On a Windows machine there is a GitLab-Runner run from a domain user with admin rights. When I log as this user and call dotnet build -c release to build an ASP.NET Core app, the dll has all the information from the AssemblyInfo.cs file. When I do the same as part of a CI job, the produced dll is missing all this information (for example the version number).
The AssemblyInfo.cs file is not part of the repository, instead, it is produced by a prebuild event (using gitWCRev.exe tool). However after running some tests I can see that the AssemblyInfo.cs is actually generated when the job is run by the runner.
Any help as to why the file is ignored and how to overcome this issue would be appreciated.
At first I thought that this might be related to Pre-build task of Visual Studio project fails in GitLab Runner issue, but I don't get any build errors.
On the same machine, I build a .Net Framework app which has the same AssemblyInfo setup, but is compiled using msbuild /property:Configuration=Release by the runner and the produced dll file has all the expected information.
It turns out the problem was partially related to the AssemblyInfo.cs file not being part of the repository.
SDK-style csproj normally don't list the files in the project, but figure them out based on the folder contents. When dotnet build was run, AssemblyInfo.cs wasn't present in the project directory (GitLab-Runner usually clears out files not present in the repository before starting a job/pipeline), so build tools had no idea they needed to load it. It made no difference that the file was being created by the build tools.
The solution proved to be creating an empty AssemblyInfo.cs file before running dotnet build. This way build tools knew they needed to compile it. Actual compilation still happened after prebuild events, so all the needed information was there.
I created the empty AssemblyInfo.cs file using PowerShell:
New-Item -Path "Properties/AssemblyInfo.cs" -ItemType File
Also, checking the build logs helped me finally figure it out. To get the build logs I've called build tools like this:
dotnet build -c release /flp:v=diag
The .Net Framework app didn't have this problem because it wasn't an SDK-style project. All the files needed for compilation were listed in the project file and build tools knew to load them, even if they were created during the prebuild event.

How to build a selection of Qt5 submodules from source?

The Qt download page (http://download.qt.io/official_releases/qt/5.12/5.12.2/) offers multiple source archives that can be used to build Qt5 from source. One contains all sources, which I managed to build successfully, but it takes rather long and contains a lot of stuff that I do not use.
They also offer submodule source packages that can be used to only build a subset of what Qt offers. Howerver I could not find a manual on how to properly build these. I need the QtBase and the QtXmlPatterns packages. I manged to build the QtBase package on its own, but I would like to know how to build multiple of the submodules.
The QtXmlPatterns package can not be build on its own, so I tried to simply copy the sources from the QtXmlPatterns submodule into the QtBase submodule. But that gives me errors when I execute the configure step.
So what is the correct procedure for combining multiple of the submodule source packages into one setup that can be build?
Thank you for your time.
Edit:
Not sure if it is relevant, but I am building Qt5.12.2 on Windows with Visual Studio 2019.
The build flow is a bit different from building the full source package.
configure and build qtbase stand-alone as you have already done it. Use a PREFIX so that you can call make install and install the build results to some location in your file system.
you may want to add the resulting bin folder to your PATH environment variable
extract the other submodule you want to build into a separate folder
run qmake, make and make install on your submodule as if it was a "normal" Qt project. This will install the submodule to the PREFIX location of qtbase.

Build and Install clRNG

For a project i need Random Numbers in an OpenCL Kernel. I found the clRNG library which is exactly what i need.
https://github.com/clMathLibraries/clRNG
But i have some trouble with installing it. I follows the Installation intructions on Github for the install with VisualStudio. I comiled the files with Cmake and got a clRNG.sln File. I can open this file with visual studio but i dont know whats the next step.
It would be great if someone could give me a detaild step-by-step guide for installing the library.
Thanks a lot.
Maybe you figured this out by yourself already, but here is the guide anyhow:
Build the ALL_BUILD project, either by going to Build -> Build Solution or right-clicking ALL_BUILD in the Solution Explorer and selecting Build.
Build the INSTALL project under CMakePredefinedTargets in the Solution Explorer by right-clicking on it and selecting Build.
Now all the needed files should be in the package folder inside the solution folder.
To use the library in a VS project, you need to the project properties and adding the clRNG include folder in the project Include Directories and the lib/import folder in the project Library Directories. You can find the settings by going to the project properties and selecting Configuration Properties -> VC++ Directories.

RStudio project and git repository in subdirectory

When developing packages in RStudio.
By default RStudio assume your package directory is the project directory and it looks like that:
But you are allowed to point the package location to a subdirectory of the project directory and it looks like that:
This way you can have some part of your project files, kept in the root project directory, not included in the package. You don't need to set git ignore etc.
But if you want to add RStudio git repo features, you are not allowed to point your git repo in subdirectory, even if you have already created git repo in your package dir (not project dir) you cannot set it in RStudio. I'm stuck at:
Is there any way to enable git repo features in RStudio having git repository in the subdirectory of the RStudio project? Maybe some .Rproj config tweaks?
Very good question. I've experienced the same trouble and it also does not go away with the latest pre-test release. So there's likely no super quick solution to this inside rstudio. Though it might be worth a feature request.
Personally I use the console / git bash with git and rstudio. That is I create a project inside R studio and manually run git init outside rstudio. Also I add, commit, merge, push and pull outside rstudio. If you don't like to manage git via console there's https://windows.github.com/ and https://mac.github.com/ also the folks at Atlassian provide some GUI tool called source tree: https://www.atlassian.com/software/sourcetree/overview
Plus there are many others, like Tortoise Git which I haven't tested, but I think R Studio's current git support is fine for simple things, but a git tool (console or gui) is definitely the way to go if you want to be more flexible.
That being said, sublime text edit is a powerful and easy to hack and customizable text editor which also has quite some packages to extend it. It's not entirely free but sometimes it's a nice supplement to rstudio. And it has a cool resolve conflict package etc.

Resources