I have an .WPF application.Using XBAP project the project as web application. The solution file having 15 projects. Among 15 projects, one is root project names 'cp'. This has other project dll. i am able to build the code. My goal is that to Publish in one Location (Ex: c:\publish)in the file format of '.deploy' of all the project(Ex: sampleproject.dll.deploy). How command should i use.? I have tried following command one by one. Nothing give proper .deploy package.
R&D
msbuild cp.sln /p:DeployOnBuild=true /p:PublishProfile=Test
msbuild cp.sln /p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="C:\Publish";AutoParameterizationWebConfigConnectionStrings=false
msbuild cp.sln /p:DeployOnBuild=true;DeployTarget=Package
msbuild cp.sln /p:DeployOnBuild=true /p:PublishProfile=FileSystemDebug
msbuild cp.sln /p:DeployOnBuild=true /p:PublishProfile=myprofile
msbuild cp.csproj /p:DeployOnBuild=true /p:PublishProfile=myprofile.
msbuild cp.csproj "/p:Platform=AnyCPU;Configuration=Release;PublishDestination=C:\Publish" /t:PublishToFileSystem
If you set your publish profile and publish directory is "c:\publish" you should use the following windows commands. I suppose that You are using MSbuild 14.0.
For Windows Machine
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /p:DeployOnBuild=true /p:PublishProfile="C:\PublishProfiles\testprofile.pubxml" "C:\Myapp\Myproject.sln"
For Azure
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /p:DeployOnBuild=true /p:AllowUntrustedCertificate=true /p:PublishProfile="C:\PublishProfiles\testprofile.pubxml" /p:Password=xxxxx "C:\Myapp\Myproject.sln"
Related
Asking very generally as I am completely new to Gitlabs CI/CD and CI/CD in general.
I have implemented a C# Net Framework application in Visual Studio 2017 and manage it with Gitlab.
Now I want to automatically create a binary of that application with the GitLab CI/CD feature.
I already have a runner ( docker based on Windows) registered in GitLab and run jobs.
My current YAML file looks as following:
default:
image: ruby:2.7.2
job:
stage: build
only:
- branches
script:
- set -m
- echo "Start build"
- '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" /p:Configuration=Release /clp:ErrorsOnly; Build "NameOfApplication.sln"'
artifacts:
expire_in : 1 days
paths:
- '.\IndoorNavigation\bin\Release'
How can I now get the artifact / binary MSBuild generates? It should show up in pipelines for download right? I already tried the artifacts option with different path unsuccessfully.
Would also be happy for links to good tutorials as I have not found any tutorial that helped me.
Edit: Output of the Job:
Running with gitlab-runner 14.3.1 (8b63c432)
on docker-runner 2tZDZ6cX
Preparing the "docker" executor
Using Docker executor with image ruby:2.7.2 ...
Pulling docker image ruby:2.7.2 ...
Using docker image sha256:e6c92ed2f03be9788b80944e148783bef8e7d0fa8d9755b62e9f03429e85a327 for ruby:2.7.2 with digest ruby#sha256:1dd0106849233fcd913b7c4608078fa1a53a5e3ce1af2a55e4d726b0d8868e2f ...
Preparing environment
00:01
Running on runner-2tzdz6cx-project-1235-concurrent-0 via d98bb3402720...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/user/NameOfApplication/.git/
Checking out 2e50e922 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
Using docker image sha256:e6c92ed2f03be9788b80944e148783bef8e7d0fa8d9755b62e9f03429e85a327 for ruby:2.7.2 with digest ruby#sha256:1dd0106849233fcd913b7c4608078fa1a53a5e3ce1af2a55e4d726b0d8868e2f ...
$ set -m
$ echo "Start build" - '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" /p:Configuration=Release /clp:ErrorsOnly; Build "NameOfApplication.sln"'
Start build - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" /p:Configuration=Release /clp:ErrorsOnly; Build "NameOfApplication.sln"
Uploading artifacts for successful job
00:01
Uploading artifacts...
WARNING: .\NameOfApplication\bin\Release: no matching files
ERROR: No files to upload
Cleaning up project directory and file based variables
00:01
Job succeeded
I have this one liner that can publish my project:
& "$($linkToMSBuildEXE)" "$($solutionName)" /t:projectName /p:Configuration="Release"
I need to publish this project and set the assemblyVersion and fileVersion of the output executable. I have tried adding the version:
& "$($linkToMSBuildEXE)" "$($solutionName)" /t:projectName /p:Configuration="Release"/p:Version=1.1.1.1
This doesn't seem to work. Do I need to add an entry to the csproj file? How can I set the versions via the command line.
Install MSBuild.AssemblyVersion package from NuGet.
Use the following or similar command line:
msbuild project.csproj /t:Rebuild /p:AssemblyVersionNumber=1.2.3.4
I am doing automation using selenium and c#. Everything is running file when I run from visual studio but getting issue in file path then run via jenkins.
Batch command I am trying :
"nuget.exe" restore UnitTestProject1.sln
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" UnitTestProject1.sln
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\MSTest.exe" /testcontainer:UnitTestProject1\bin\Debug\UnitTestProject1.dll
Output from Jenkins :
Building in workspace C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1
[UnitTestProject1] $ cmd /c call C:\Users\developer\AppData\Local\Temp\jenkins934555759751738078.bat
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>"nuget.exe" restore UnitTestProject1.sln
MSBuild auto-detection: using msbuild version '15.5.180.51428' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\bin'.
All packages listed in packages.config are already installed.
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" UnitTestProject1.sln
Microsoft (R) Build Engine version 4.6.1055.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 3/5/2018 6:38:36 PM.
Project "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1.sln" (1) is building "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1\UnitTestProject1.csproj" (2) on node 1 (default targets).
Project file contains ToolsVersion="15.0". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="4.0". For more information, please see http://go.microsoft.com/fwlink/?LinkId=291333.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
_CopyOutOfDateSourceItemsToOutputDirectory:
Skipping target "_CopyOutOfDateSourceItemsToOutputDirectory" because all output files are up-to-date with respect to the input files.
_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
UnitTestProject1 -> C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1\bin\Debug\UnitTestProject1.dll
Done Building Project "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1\UnitTestProject1.csproj" (default targets).
Done Building Project "C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1\UnitTestProject1.sln" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.03
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\MSTest.exe"
Microsoft (R) Test Execution Command Line Tool Version 15.0.27019.1
Copyright (c) Microsoft Corporation. All rights reserved.
Please specify tests to run, or specify the /publish switch to publish results.
For switch syntax, type "MSTest /help"
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>/testcontainer:UnitTestProject1.dll
The filename, directory name, or volume label syntax is incorrect.
C:\Users\developer\.jenkins\workspace\LinkedinAutomation\UnitTestProject1>exit 123
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
It seems everything is fine till end. It has issue in finding project dll file at end with test container.
I have the following set as a Windows Batch command:
. This is one long line that runs the individual project Test DLLs of our components. Each DLL is from a Unit Test Project.
It appears that your command line has forward slashes, and not the Windows directory separator, the backslash.
I have also found that I needed a different command line to get my tests running properly. I had to use the vstest.console.exe to run the tests.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" Application_Tests\bin\Release\Application_Tests.dll AppLib_Tests\bin\Release\AppLib_Tests.dll
For the full command line: vstest.console.exe command line
I am using the new MSBuild 15 distributed with VS2017 RC to compile and pack a multi targeting project.
Restoring: msbuild /t:restore mysolution.sln works correctly.
Building: msbuild /p:Configuration=Release mylibrary.csproj works correctly and generates:
+ bin/Release
+ netstandard1.4
- mylibrary.dll
+ net452
- mylibrary.dll
But when I am packing: msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true mylibrary.csproj the structure does not match well with the previous build, looking like:
+ bin/Release
+ netstandard1.4
- mylibrary.pdb
+ net452
- mylibrary.pdb
- mylibrary.dll
Warnings from the /t:pack command show me this was gonna happen, but not sure how to solve it:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Issue found with package 'MyLibrary'. [D:\XXX\YYY\src\MyLibrary\MyLibrary.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Issue: Assembly not inside a framework folder. D:\XXX\YYY\src\MyLibrary\MyLibrary.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Description: The assembly 'lib\MyLibrary.dll' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Solution: Move it into a framework-specific folder. If this assembly is targeted for multiple frameworks, ignore this warning.
Notes:
I am not using a *.nuspec file. Just the new way *.csproj files work (https://docs.nuget.org/ndocs/schema/msbuild-targets#pack-target)
This is how some of the relevant content of the file look like:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>library</OutputType>
<TargetFrameworks>netstandard1.4;net452</TargetFrameworks>
<AssemblyName>MyLibrary</AssemblyName>
<Authors>XXX</Authors>
<Description>YYY</Description>
<PackageId>MyLibrary</PackageId>
<PackageVersion>1.2.3</PackageVersion>
</PropertyGroup>
</Project>
Thanks for your comments. I found my way on based on them.
This is what I did: I downloaded the dotnet cli tool again and test it from scratch. I realized that the version of the cli tool were the same so I started comparing the files inside.
Wrong dotnet cli version
The version that was not working contained the following files:
+ dotnet
+ sdk
+ 1.0.0-preview2-1-003177
+ 1.0.0-preview2-003131
+ 1.0.0-preview2-003133
+ 1.0.0-preview4-004233
Using dotnet build /t:pack /p:Configuration=Release /p:IncludeSymbols=true mylibrary.csproj showed the following error:
Couldn't find 'project.json' in '/t:pack'
Good dotnet cli version
The second version I downloaded contained only these:
+ dotnet
+ sdk
+ 1.0.0-preview4-004233
And executing the command before, it works correctly:
Microsoft (R) Build Engine version 15.1.458.808
Copyright (C) Microsoft Corporation. All rights reserved.
...
I have a C# solution with 3 projects.
App.Console\App.Console.csproj
App.Web\App.Web.csproj
App.Shared\App.Shared.csproj
Both App.Console and App.Web reference App.Shared. Currently, I build each project separately as they have slightly different MSBuild arguments.
My current build process is as follows
MSBuild.SonarQube.Runner.exe begin /k:"MyApp" /n:"My App" /v:"1.0"
msbuild.exe msbuild App.Console\App.Console.csproj /t:'Rebuild' /p:Configuration=Release /p:OutDir=C:\Out\Console
msbuild.exe msbuild App.Web\App.Web.csproj /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=C:\Out\Web
MSBuild.SonarQube.Runner.exe end
I see statistics for both App.Console and App.Web, however, statistics for App.Shared is missing. Instead, I notice a warning in the SonarQube runner output.
WARNING: Duplicate project GUID: "21889c3d-d9c4-40d6-a4e4-971735d19ee2". Check that the project is only being built for a single platform/configuration and that that the project guid is unique. The project will not be analyzed by SonarQube. Project file: C:\Projects\MyApp\App.Shared\App.Shared.csproj
I believe this warning is the root of my problem.
If I do the following:
MSBuild.SonarQube.Runner.exe begin /k:"MyConsoleApp" /n:"My Console App" /v:"1.0"
msbuild.exe msbuild App.Console\App.Console.csproj /t:'Rebuild' /p:Configuration=Release /p:OutDir=C:\Out\Console
MSBuild.SonarQube.Runner.exe end
MSBuild.SonarQube.Runner.exe begin /k:"MyWebApp" /n:"My Web App" /v:"1.0"
msbuild.exe msbuild App.Web\App.Web.csproj /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=C:\Out\Web
MSBuild.SonarQube.Runner.exe end
I now have 2 separate projects in SonarQube which both contain statistics for App.Shared. This is bad because this information is duplicated between the two projects and does not accurately give me an overall technical debt for my solution.
I have been able to get all three set of statistics in one project by building the solution only:
MSBuild.SonarQube.Runner.exe begin /k:"MyApp" /n:"My App" /v:"1.0"
msbuild.exe msbuild App.sln /t:'Rebuild' /p:Configuration=Release
MSBuild.SonarQube.Runner.exe end
This is not ideal because building the solution does not build the web project the way I need, thus I must do a 2nd build after SonarQube completes (build the way I need it, not the way SonarQube wants it).
Is it possible to run msbuild multiple times in-conjunction with the SonarQube MSBuild runner and get one set of complete statistics?
In the shared app, you can conditionally set a <SonarQubeExclude>true</SonarQubeExclude> property, such that it will be set only when building either App.Web or App.Console.
You can find a proposal on how to achieve this in the Microsoft ALM Rangers guide to SonarQube under Appendix 3, "Explicitly associating an MSBuild project with a SonarQube project": http://redirect.sonarsource.com/doc/sq-setup-guide-for-dotnet-users.html
The issue might be that you have an extra *.sln file in your solution. I encountered this when there was an old, dormant .sln file in a project folder. Deleting it resolved the issue.