Under what cases does a VSTS build produce an empty drop - c#

I have a .Net (VS 2015) application that I manually build using VSTS. The build was successfully completed but no artifacts were generated. The agents/tasks used in this manual build are the NuGet tool installer, NuGet restore, Visual Studio build, publish build artifact.
Visual Studio Build parameters:
Publish Build Artifact parameters:
Variables added:
End Result:
A similar structure should be produced as per my expectation:

Before the "Publish artifacts" task, you need to copy to the folder a in the agent the files you want they will be in the artifacts.
For example:
Now in your artifacts folder (a on the agent) will be your release output and in the Publish task it will be published as artifacts.

Related

Creating MSIX using msbuild produces "doesn't have a target" error but works in Visual Studio

I have three WPF applications that I am including in a MSIX package. I have a solution that contains the three applications along with shared projects and a "Windows Application Packaging Project". I can build the MSIX by Choosing Publish -> Create App Packages on the Packaging project in Visual Studio. I am choosing Sideloading with a self-signed certificate and a Release (Any CPU) option.
This produces the MSIX output as expected.
I'm now trying to do the same thing through MSBuild so that I can integrate this into our automated build system. I'm using the command:
MSBuild.exe /restore /p:AppxBundle=Never /p:UapAppxPackageBuildMode=Sideloading /p:Configuration=Release;Platform="Any CPU" /p:AppxPackageDir=C:\temp\Output\ /p:AppxPackageSigningEnabled=false
This produces errors for the WPF applications as per below.
:\Repos\app\app.sln" (default target) (1:2) ->
"C:\Repos\app\appPackage\appPackage.wapproj" (default target) (19:6) ->
"C:\Repos\app\app\app.csproj" (publish target) (2:18) ->
C:\Program Files\dotnet\sdk\6.0.107\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file 'C:\Repos\app\app\obj\project.assets.json' doesn't have a target for 'net6.0-windows10.0.19041/win-x86'. Ensure that restore has run and that you have included 'net6.0-windows10.0.19041' in the TargetFrameworks for your project. You may also need to include 'win-x86' in your project's RuntimeIdentifiers. [C:\Repos\app\app\app.csproj]
Why does this work in Visual Studio, but no in MSBuild? And how can I get this to work in MSBuild?

MSBuild ignoring /p:BuildProjectReferences=false on Azure build server

I've a solution with three projects in it: 2 C# WPF projects and 1 WIX project to create an installer. I've set up a build pipeline on Azure DevOps that references our own build server so I have access to the OS.
I want the Wix installer project to be dependant on the two C# projects for my local test builds but for the Azure Pipeline, I need to build the C# projects first and sign the executables before creating the MSI installer with the WIX project (that needs to be signed, too).
The problem is that the build server ignores "/p:BuildProjectReferences=false" (which should force msbuild to NOT build the dependencies) while my local computer does not when I run the exact same command line on both:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" Solution.sln /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /p:RunWixToolsOutOfProc=true /p:BuildProjectReferences=false /target:Installer /m:4 /p:Platform="x64" /p:Configuration="Release"
Extra info
I tried with and without Rebuild option (/target:Installer:Rebuild)
The build server fetches the git repository so it's exactly the same project on both sides.
Both Visual Studio installations are VS 2019 build version 16.11.14
Both Wix Toolset installations are version v3.11.2.4516
Any ideas how to get the build server to not build the dependencies?
Well this is embarrassing. Apparently I had some change on my local computer that wasn't committed yet. So code on both platforms wasn't the same...
The fix was a change in the *.sln file
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "Installer\Installer.wixproj", "{A9EDFE69-D273-42EE-97EA-469C3434AEDC}"
ProjectSection(ProjectDependencies) = postProject
{C784B33D-1E8D-41EF-97C2-983CA9A5B693} = {C784B33D-1E8D-41EF-97C2-983CA9A5B693}
{B6E37FA9-64CF-491B-B268-9D115AABC6B2} = {B6E37FA9-64CF-491B-B268-9D115AABC6B2}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFProject1", "WPFProject1\WPFProject1.csproj", "{C784B33D-1E8D-41EF-97C2-983CA9A5B693}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFProject2", "WPFProject2\WPFProject2.csproj", "{B6E37FA9-64CF-491B-B268-9D115AABC6B2}"
EndProject
I removed the 'ProjectSection' in the first project (Installer). This resulted in the code being built completely in Visual Studio but not for the Azure Pipelines because of the use of the /p:BuildProjectReferences=false param in the pipeline build command.
The two WPF projects still exist as depedencies in Installer project.
I hope this helps someone someday (or myself in a future project)

Run SonarCloud Analyze Manually From Visual Studio

I have paid account in Sonarcloud and Gitlab CI for automation, I use Visual Studio with integrated SonarLint for C#. Sometimes I want to run analyzing manually from VS and not using Gitlab runner every time. Is there a way to bypass pipeline? The reason is that I have limitations for runner minutes and I want to make commit and run pipeline only when I cleanup code warnings from SonarLint.
SonarScanner
You can trigger a SonarCloud analysis locally using SonarScanner:
SonarScanner for MSBuild as a stand-alone executable.
.NET Core global Tool installed with NuGet, also called as executable.
Download the SonarScanner CLI binary and run it from the command line.
The MSBuild option looks something like this:
SonarScanner.MSBuild.exe begin /k:"project-key"
MSBuild.exe <path to solution.sln> /t:Rebuild
SonarScanner.MSBuild.exe end
The .NET Core global tool looks like this:
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:"project-key" /d:sonar.login="myAuthenticationToken"
dotnet build <path to solution.sln>
dotnet sonarscanner end /d:sonar.login="myAuthenticationToken"
Since You need to call SonarScanner before and after a build. you can integrate the SonarScanner commands in Visual Studio using Build Events. Add the commands to PreBuildEvent.bat and PostBuildEvent.bat to run the analysis automatically every time you build. If you don't want to run SonarScanner every time you build, create a new custom build configuration (e.g. Debug, Release, Analyze).
You will need to generate a private token for your project key in SonarCloud. The final report will also be available in that project when it is ready.
SonarLint
If you don't need to update SonarCloud and just want to view the code analysis results, you can use SonarLint Visual Studio extension. You can connect SonarLint with SonarCloud to download your common configuration using a feature called Connected Mode.
Connected mode does not push issues to the server. Rather, its purpose is to configure the IDE so that it uses the same settings as the server.
A summary of instructions (see Connected Mode for details):
Open the Team Explorer Home tab and click on the SonarQube icon
Click on Connect... to display the connection dialogue
Select the server and enter your credentials
Select the Organization (SonarCloud only)
Select the Sonar project to bind to
SonarLint will then fetch the required settings from the server and create local configuration files
Your code will be analyzed live (as you type), or you can run a full code analysis as follows:
Right click solution -> Analysis -> Run Code Analysis
You can't do this from Visual Studio, but you can make this like powershell script.

Visual Studio 2015 builds my project without problems, MSBuild.exe cannot

I am developing simple Asp.net MVC 5 app which is working ok and visual studio 2015 can build it without any issues, but when i use MSBuild.exe command line tool it shows alot of errors which relates to typescript files compilation (primarily from node_modules folder).
I am trying to use Jenkins CI tool to automate my deployment routine, in order to do so i have to build my app using MSBuild.exe.
My project has tsconfing.json file in the root folder which contains following lines to exclude node_modules folder (it is inside #AngularComponents folder):
"exclude": [ "Scripts/**", "WrittenScripts/#AngularComponents/**" ]
But somehow MSBuild.exe command line tool just ignores it during build.
Does anyone have any ideas how to configure it to take into account my tsconfig? or tell MsBuild to not to build my node_modules folder?
Thank you in advance!
I finally figured it out.
First of all i have to use this MsBuild:
1) C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe;
Secondly, for some reason msbuild messed up my tools version 4.0 so I need to pass additional parameter to msbuild:
2) /tv:14.0
Thirdly, my typescript files have some /// references to node_modules\#types folder and for some reason it shows me any errors but not related to the reference one.
3) so i have to run npm install to recover #types packages.
After these steps msBuild builds successfully without any errors.
Thanks for all!

TFS Build Server won't deploy my .pdbs

The steps of my build:
NuGet Installer - get all packages for all solutions in the source tree
Visual Studio Build - Build the solution - no special parameters
Visual Studio Test - Run tests on built solution
Visual Studio Build - Publish specific website - MSBuild Arguments = /p:DeployOnBuild=true /p:PublishProfile=Publish /p:OutputPath=Publish /p:TeamDirectory="$(TeamName)\\" /p:ExcludeGeneratedDebugSymbol=false
Publish Build Artifacts
Additional configuration:
Going to properties for the website in VS, all build configurations have "Exclude generated debug symbols" unchecked. This is reflected in the .csproj file with <ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol> under each PropertyGroup.
Going to properties for the website in VS, under Build -> Advanced, all build configurations have Debug Info = pdb-only (except Debug, which has full). This is reflected in the .csproj file with <DebugType>pdbonly</DebugType> and <DebugSymbols>true</DebugSymbols>
The bin directory for all projects including the website contains appropriate .pdb files. The Publish directory and the generated artifact do not have any .pdb files except for Antlr3.Runtime.pdb, EntityFramework.MappingAPI.pdb, and RefactorThis.GraphDiff.pdb. Running publish locally through VS copies the .pdb files as expected.
I tested at my side, TFS has the same behavior with local VS, it's the default behavior.
Normally the Antlr3.Runtime.pdb and project project.pdb will display there, If you have other third packages, you need to make sure the .pdb files are included in them when get sources.
Whatever, have a try for these arguments /p:DebugSymbols=true /p:DebugType=full

Categories

Resources