How to: Build an Access application with dotnet build
Build the database with dotnet build - on a developer machine, in CI, or from an IDE - with the same result as
wkl-office build.
Solution overview
The project file is MSBuild XML. Importing the targets of the SDK at its end gives it the targets Build, Rebuild,
Clean, Check, Validate, Export and Roundtrip; the MSBuild tasks behind them call the same classes as wkl-office.
| Command | Does what wkl-office does with |
|---|---|
dotnet build Customers.acproj | build (-p:WklAccessAccde=true or false for --accde / --no-accde) |
dotnet build Customers.acproj -t:Rebuild | rebuild |
dotnet build Customers.acproj -t:Clean | removes build/<configuration>; takes no project lock, so do not run it while another run works on the project |
dotnet msbuild Customers.acproj -t:Check, -t:Validate, -t:Export, -t:Roundtrip | check, validate, export, roundtrip; -t:Export -p:WklAccessDatabaseToExport=<file> exports another database, as -d |
Implementation
Add the import as the last element of Customers.acproj:
<Import Project="<folder of Wkl.Office.Sdk.MSBuild>\Wkl.Office.Sdk.targets" /> </Project>
dotnet build Customers.acproj -p:Configuration=Release
Remarks
- Every problem becomes an MSBuild error or warning with its file and line and the code
WKL+ the number of its phase (WKL001sources,WKL900a difference found by the roundtrip), so editors and CI logs show it at its place. - While another run works on the same project (
wkl-officein a terminal, the Access add-in), a task fails at once with errorWKL010naming that run (The project is busy). - A file another program holds open (an editor, a virus scanner) fails the task with error
WKL011naming the file and the program (A file is in use by another program). - Canceling the build (Ctrl+C, Stop in an IDE) asks the hidden Access of the running step to close and ends it after 30 seconds; no Access stays behind.
- The tasks need the MSBuild of the .NET SDK (
dotnet build).msbuild.exeof Visual Studio runs on the .NET Framework and cannot load them.
What is reproducible
The same sources, built with the same SDK version, the same Access (version and bitness), the same registered
references, the same ANSI code page and the same template and control blocks, give a database with the same objects,
tables, data and settings, and its export writes the same sources. The database file is not byte-identical between two
builds: Access gives every object loaded from text a new GUID and stores compiled code and time stamps. Pin these
inputs on build machines; the project file names no SDK version. Every dotnet build builds the whole database again;
the targets are not incremental. CI needs an interactive Windows session with Access (see
Install the SDK).