CruiseControl.NET: Ignore DB projects in a build - cruisecontrol.net

After upgrading to VS2010 we have a few .dbproj files that are causing issues in our CI builds. They do nothing except just store SQL files anyway, so I'd like to just ignore them. I'm running CruiseControl.NET and building my solution with devenv.com. Is there some way for me to tell the build that I want to ignore these projects, or all .dbproj projects?

One way to do it is to create a new solution configuration in Visual Studio. Go to the Debug menu and then Configuration Manager. Create a new configuration and then exclude your .dbproj projects.
Then use that configuration name in the command line of devenv.com instead of 'Debug' or 'Release'

Since its a just a files container project, you could just exclude it from build in Debug and Release
Use msbuild instead of devenv and it will support the 'excluded from build' feature (i think devenv doesn't)
An (somewhat) alternative would be to switch the project into a class library (which will actually will build nothing...)
An example MSBUILD task would be:
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>project_solution_path</workingDirectory>
<projectFile>project_solution_file</projectFile>
<buildArgs>/p:Configuration=Debug /p:VCBuildAdditionalOptions="/useenv" /v:diag /t:rebuild</buildArgs>
<timeout>300</timeout>
</msbuild>
HTH

Related

Ho to trace dll to some nuget package

I'm working on relatively big solution with many projects in it. Almost each project has dependencies on some nuget packages. In the output folder bit/debug/net6.0 of startup project I have found BouncyCastle.Crypto.dll and I would like to find out where it's comming from.
I have checked all the project files but there is no references to BouncyCastle.Crypto neither any reference in any of .cs files. So it must be a transient dependency.
Question is there easy way to find out nuget package from which this DLL is comming?
Is there is UI for it e.g. in Visual Studio / Resharper or if there is some command for dotnet CLI?
You can use build with --verbosity flag, like this:
dotnet build --verbosity detailed
And then, in output you can grep or search for relevant dll, you'll find something like this:
1:7>Target "_CopyFilesMarkedCopyLocal" in file "/opt/.dotnet/sdk/6.0.403/Microsoft.Common.CurrentVersion.targets" from project "/SOME_PATH/SOME_PATH/SomeProjectName.csproj" (target "CopyFilesToOutputDirectory" depends on it):
Task "Copy"
Copying file from "/SOME_PATH/.nuget/packages/bouncycastle/1.8.9/lib/BouncyCastle.Crypto.dll" to "/SOME_PATH/SOME_PATH/bin/Debug/net6.0/BouncyCastle.Crypto.dll".
Done executing task "Copy".
from project line, will point you to the actual project. Copying file from and to will point to the actual dll.

Azure Build Pipeline: VSBuild fails on The CodeDom provider

My build pipeline (Microsoft-hosted agent) has been running every morning for a couple of months but this morning it suddenly failed on the VSBuild task. The error is described as:
"##[error]ASPNETCOMPILER(0,0): Error ASPCONFIG: The CodeDom provider type "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" could not be located."
See image of failed build here
How do i fix this?
Not sure if you use private agent. As I know this error could result from the fact that PrecompileBeforePublish property is set to true somewhere in your project.(csproj or publish profile).
As one workaround you can pass /p:PrecompileBeforePublish=false as argument to your VSBuild Task. But this may make first response of your application slow.
Or you can register it into GAC using command like this:
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\xxxx\VSEditon\Common7\IDE\PublicAssemblies\CppCodeProvider.dll"
Cause after VS2017, the C++ project support for xsd.exe is deprecated, we need to manually add its assembly into GAC as described here.
I managed to solve this by just skipping build on the assets project that failed. This was done using the Configuration Manager in Visual Studio (found in Build->Configuration Manager). I just removed the check mark. See attached images for clarification.
Skip project build
Configuration Manager

Compile directory in Azure DevOps Repos and save the results somewhere

Let’s say I have a directory structure like this in an Azure DevOps repo:
Main/
- A/
- *.csproj
- B/
- *.csproj
- C/
- *.csproj
Each subfolder has a .csproj file. I want to compile the Main/A/ folder and save the build results (artifacts?) somewhere, be it a folder or something else. How do I tell Azure to build that precise Main/A/*.csproj file and do I need to use /p:OutputPath inside the VSBuild#1 task, or do I need to use some other Azure task?
How do I tell Azure to build that precise Main/A/*.csproj file and do
I need to use /p:OutputPath inside the VSBuild#1 task
If you're using classic UI, you need to unlink the default solution:
And then choose the A project by the browse option:
If you're using Yaml format, you should use something like solution: A/A.csproj to specify which project to build.
Note:
Since now we're building single project instead of whole solution, we should use Project Configuration instead of Solution Configuration. any cpu is Solution Platform instead of Project Platform(AnyCPU). So we should make sure we're building single project with AnyCPU if we want to build one project with this setting.
If you got error The OutputPath property is not set for project 'A.csproj', that indicates you should use valid project configuration. In your case, if you're using any cpu, change it to AnyCPU.
In addition:
1.To publish the build results as build artifacts for further use. You can use Copy Files task and Publish Build Artifacts task like this:
Copy Files Task.
Publish Build Artifacts
Then you can download the Test.zip in Summary tab from build log page. Also, you can use this artifact in release pipeline by using download artifacts task.
Check this, if you're trying build code project instead of whole solution. You can consider MSBuild Task. They(Msbuild task,VS Build task) both calls msbuild.exe to do the build job.
Hope all above helps :)

Can Visual Studio 2012 do a custom build such as: compile project A > compile and link project B > link project A?

I am looking for a way to builds projects in this order with Visual Studio 2012 (C++ but might be a general question):
Compile ProjectA (I just need the .objs)
Compile and link ProjectB
Link ProjectA
I can't simply use a reference/dependency of ProjectA in ProjectB because it will perform the link of ProjectA too early.
I used to do this with VS 2008 this way:
PreBuild Event on ProjectB: vcbuild /pass0 /pass1 ProjectA
Compile and link ProjectB (which is a dependency of ProjectA)
Compile (actually does nothing as it was already built) and link ProjectA
But vcbuild is gone from VS 2012 and I replaced the command with:
msbuild /t:BuildGenerateSources /t:BuildCompile
The problem here is that at the 3rd step where it's supposed to only link (since msbuild already compiled) it now compiles again ProjectA and then links it. Enabling diagnostic verbosity with msbuild showed me this: Forcing rebuild of all source files due to a change in the command line since the last build.. And pretty much no one (including Visual Studio 2010 randomly says the command line changed, and rebuilds) has a solution for this as it's impossible to see what 2 commands are being compared.
The other benefit of doing what I'm looking for directly with Visual Studio (without a prebuild event that launches msbuild in a command line), would be to have compile errors reported to the Errors list and clickable in the Output window.
Maybe under the hood this would use msbuild and Targets specified in vcxprojs but I'd like to know if it's doable at all.
Edit: I have already tried to replace the command calling msbuild by devenv but there is no switch for devenv that can specify compile only (no linking), so it can't be used either.
Edit2: Sound like someone already asked something similar here (no solution) Is it possible for Visual Studio C++ to compile objects without linking
Ok so it can be done by overriding BuildSteps in the .vcxproj and removing the target BuildLink.
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<BuildSteps Condition="'$(BuildSteps)' == '' or '$(SkipLink)'!='false'">
ResolveReferences;
PrepareForBuild;
InitializeBuildStatus;
BuildGenerateSources;
BuildCompile;
<!-- BuildLink; -->
</BuildSteps>
</PropertyGroup>
When VS builds it will not perform the link step.
The original BuildSteps are defined in C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.BuildSteps.target
To finally link the project on the command line later (from a build event on another project for example) we call:
msbuild /t:BuildLink /p:VisualStudioVersion=11.0 /p:Configuration=Debug /p:Platform=x64 /p:SkipLink=false "ProjectA.vcxproj"
Notice that a condition SkipLink has been added to the BuildSteps override so we can specify when to perform the BuildLink and when not to.

CruiseControl.Net Failed Build - No explanation

I am just beginning to set up a Continuous Integration Server using CruiseControl.Net. To keep things simple to begin with, I used the Visual Studio Task to carry out the build, pointing it at the project solution file. However, when the build process occurs, CC.Net successfully gets the latest source version from Subversion, and appears to run the devenv command. The build process then fails, but there is no explanation about why. Here is the output:
BUILD FAILED
Project: MyProject
Date of build: 2009-09-09 16:31:13
Running time: 00:00:49
Integration Request: Dashboard triggered a build (ForceBuild)
Modifications since last build (0)
Tests run: 0, Failures: 0, Not run: 0,
Time: 0 seconds No Tests Run This
project doesn't have any tests
There is nothing else displayed on the page. My XML Logs don't show any build results either.
This is my configuration file:
<!--<ccnetconfig><configurationVersion>1.4</configurationVersion></ccnetconfig>-->
<cruisecontrol>
<project name="MyProject">
<workingDirectory>C:\Users\Builder\Desktop\builder-pc\MyProject</workingDirectory>
<sourcecontrol type="svn">
<trunkUrl>svn://builder-pc/MyProject/trunk</trunkUrl>
<workingDirectory>C:\Users\Builder\Desktop\builder-pc\MyProject</workingDirectory>
<executable>C:\Program Files\Subversion\bin\svn.exe</executable>
<autoGetSource>True</autoGetSource>
<tagOnSuccess>True</tagOnSuccess>
</sourcecontrol>
<tasks>
<devenv>
<solutionfile>C:\Users\Builder\Desktop\builder-pc\MyProject\trunk\MyProject.sln</solutionfile>
<configuration>release</configuration>
<buildtype>Rebuild</buildtype>
<executable>C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe</executable>
<buildTimeoutSeconds>600</buildTimeoutSeconds>
</devenv>
</tasks>
</project>
</cruisecontrol>
I have deliberately removed things like the SVN username and password.
Building the solution using the VS Command Prompt works, albeit with warnings. This is using the same swtiches that CC.Net would be using.
Can anyone help? Is it failing because there are no unit tests to run, or because of the warnings? Or is it best to switch to MSBuild or NAnt instead of using the Visual Studio Task?
If there is no useful information in the build log, try looking at the server log for information about the failure.
I think the reason you aren't seeing any output in the xml log files is because you don't have an appropriate <publishers> section in your <project>.
Try:
<publishers>
<xmllogger />
</publishers>
Try running the build with MSBuild instead of devenv.exe. If the log gets merged into the xml but is not displayed properly in the web dashboard, make sure that appropriate xsl transforms are enabled. Also, as Scrappydog mentioned, add the xmllogger publisher (although it should be added by default if you don't have any publishers defined at all, you can check this in the 'Project Configuration' page on the dashboard.
You should use devnev.com (note the file extension is .com, not .exe) in the same path (i.e. C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE), instead of devnev.exe.
The <executable> block is optional, and from the CruiseControl.NET documentation, it will use the latest version of devnev.com, not devnev.exe.

Resources