diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e90e17..da6b8a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,56 +1,37 @@ -# This file is a template, and might need editing before it works on your project. -# The following script will work for any project that can be built from command line by msbuild -# It uses powershell shell executor, so you need to add the following line to your config.toml file -# (located in gitlab-runner.exe directory): -# shell = "powershell" -# -# The script is composed of 3 stages: build, test and deploy. -# -# The build stage restores NuGet packages and uses msbuild to build the exe and msi -# One major issue you'll find is that you can't build msi projects from command line -# if you use vdproj. There are workarounds building msi via devenv, but they rarely work -# The best solution is migrating your vdproj projects to WiX, as it can be build directly -# by msbuild. -# -# The test stage runs nunit from command line against Test project inside your solution -# It also saves the resulting TestResult.xml file -# -# The deploy stage copies the exe and msi from build stage to a network drive -# You need to have the network drive mapped as Local System user for gitlab-runner service to see it -# The best way to persist the mapping is via a scheduled task (see: https://stackoverflow.com/a/7867064/1288473), -# running the following batch command: net use P: \\x.x.x.x\Projects /u:your_user your_pass /persistent:yes - - -# place project specific paths in variables to make the rest of the script more generic variables: - EXE_RELEASE_FOLDER: 'C:\Testb\bin\Release' - MSI_RELEASE_FOLDER: 'C:\Testb\Setup\bin\Release' - TEST_FOLDER: 'C:\Testb\Tests\bin\Release' - #DEPLOY_FOLDER: 'P:\Projects\YourApp\Builds' - NUGET_PATH: 'C:\Tools\NuGet\nuget.exe' - #MSBUILD_PATH: 'C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe' - MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\msbuild.exe' - #NUNIT_PATH: 'C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe' + NUGET_PATH: 'C:\Tools\nuget.exe' + MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe' + stages: - - build - #- test - #- deploy - + - build + - deploy + +before_script: + - '& "$env:NUGET_PATH" restore sourcecode\project.sln' # sourcecode\project.sln-This path includes project solution where is available and restoring + + build_job: - stage: build - only: - - master # the build process will only be started by git tag commits - tags: - - msbuild - script: - - '& "$env:NUGET_PATH" restore' # restore Nuget dependencies - - '& "$env:MSBUILD_PATH" LPA/LPA.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m' # build the project - artifacts: - expire_in: 1 week # save gitlab server space, we copy the files we need to deploy folder later on - paths: - - '$env:EXE_RELEASE_FOLDER\LPA.exe' # saving exe to copy to deploy folder - - '$env:MSI_RELEASE_FOLDER\LPA.msi' # saving msi to copy to deploy folder - #- '$env:TEST_FOLDER\' # saving entire Test project so NUnit can run tests + stage: build + only: + - developer #this branch will run on GitLab Runner and can change it. + script: + - '& "$env:MSBUILD_PATH" sourcecode\project.sln /p:DeployOnBuild=true /p:Configuration=Release /p:Platform="Any CPU" /P:PublishProfile=FolderProfile.pubxml' + - bat "\$env:MSBUILD_PATH" LPA/LPA.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m" + + artifacts: + expire_in: 365 days #artifcats will be stored only 365 days after this it will expire + paths: + - '.\sourcecode\project.sln\bin\Release\Publish\' + - '.\sourcecode\project.sln\bin\Publish\' + + dependencies: + - build_job +deploy_job: + stage: deploy + only: + - developer #this branch will run on GitLab Runner and can change it. + script: + - 'xcopy /y /s ".\sourcecode\project.sln\bin\Release\Publish\*.*" "C:\solutionDir"' #Path where you want to store the solution diff --git a/.gitlab-ci.yml_bck b/.gitlab-ci.yml_bck new file mode 100644 index 0000000..1e90e17 --- /dev/null +++ b/.gitlab-ci.yml_bck @@ -0,0 +1,56 @@ +# This file is a template, and might need editing before it works on your project. +# The following script will work for any project that can be built from command line by msbuild +# It uses powershell shell executor, so you need to add the following line to your config.toml file +# (located in gitlab-runner.exe directory): +# shell = "powershell" +# +# The script is composed of 3 stages: build, test and deploy. +# +# The build stage restores NuGet packages and uses msbuild to build the exe and msi +# One major issue you'll find is that you can't build msi projects from command line +# if you use vdproj. There are workarounds building msi via devenv, but they rarely work +# The best solution is migrating your vdproj projects to WiX, as it can be build directly +# by msbuild. +# +# The test stage runs nunit from command line against Test project inside your solution +# It also saves the resulting TestResult.xml file +# +# The deploy stage copies the exe and msi from build stage to a network drive +# You need to have the network drive mapped as Local System user for gitlab-runner service to see it +# The best way to persist the mapping is via a scheduled task (see: https://stackoverflow.com/a/7867064/1288473), +# running the following batch command: net use P: \\x.x.x.x\Projects /u:your_user your_pass /persistent:yes + + +# place project specific paths in variables to make the rest of the script more generic +variables: + EXE_RELEASE_FOLDER: 'C:\Testb\bin\Release' + MSI_RELEASE_FOLDER: 'C:\Testb\Setup\bin\Release' + TEST_FOLDER: 'C:\Testb\Tests\bin\Release' + #DEPLOY_FOLDER: 'P:\Projects\YourApp\Builds' + NUGET_PATH: 'C:\Tools\NuGet\nuget.exe' + #MSBUILD_PATH: 'C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe' + MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\msbuild.exe' + #NUNIT_PATH: 'C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe' + +stages: + - build + #- test + #- deploy + +build_job: + stage: build + only: + - master # the build process will only be started by git tag commits + tags: + - msbuild + script: + - '& "$env:NUGET_PATH" restore' # restore Nuget dependencies + - '& "$env:MSBUILD_PATH" LPA/LPA.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m' # build the project + artifacts: + expire_in: 1 week # save gitlab server space, we copy the files we need to deploy folder later on + paths: + - '$env:EXE_RELEASE_FOLDER\LPA.exe' # saving exe to copy to deploy folder + - '$env:MSI_RELEASE_FOLDER\LPA.msi' # saving msi to copy to deploy folder + #- '$env:TEST_FOLDER\' # saving entire Test project so NUnit can run tests + + diff --git a/sourcecode/.gitkeep b/sourcecode/.gitkeep new file mode 100644 index 0000000..e69de29