Visual Studio Output Window warn on compile in Debug configuration - c#

Is there any way that I can display a custom message in my Visual Studio Output window after I compile?
I had an issue today where my project was successfully compiled and a NuGet package built and released - only to find that none of my new changes had been included in the NuGet package as I had been working in Debug config and the package picked up from \bin\release\Output.dll
I would like to display a custom message in my Visual Studio Output window when I compile in Debug configuration, ideally something along the lines of:
========== Rebuild All: 11 succeeded, 0 failed, 0 skipped ==========
*** Warning - change to Release configuration before publishing ***

You can use Build events. See Project > Properties > Build Events menu.
Write Post-build event command line:
echo "*** Warning - change to Release configuration before publishing ***"

Related

Visual Studio publish doesn't report errors

I have a WCF web service using Visual Studio 2015. If I have a compile error in C# code, when I publish the web service (to a file location) the "build" will succeed, and continue through a successful publish:
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
If I then deploy to an IIS web server and call the web service there, the call fails and returns a page describing the compilation error.
When publishing, the output in VS starts with Build started: but apparently it isn't really doing a build because any build would have failed, and in fact if I do a build instead of publish, it does report the error(s). Do I have to remember to build before publishing to check for errors, or is there a way to get it to really for realz compile the code?
If solution has many projects then try building them one at a time.
Try below steps:
Restart Visual Studio.
Restart Computer
Rebuild all
Clean Solution then Rebuild All
Also you can check below
Setting the MSBuild project build output verbosity (in Options > Projects and Solutions > Build and Run setting area) to "Diagnostic" as shown below. This then showed that the custom action was what had failed.
https://blogs.msdn.microsoft.com/saraford/2008/10/07/did-you-know-you-can-configure-the-msbuild-verbosity-in-the-output-window-329/

SonarQube can't complete the post-build step

I got a Jenkins Server set up on Windows 2012 R2. These are my build settings:
Underneath you see the error. It should be said that the pre-build step runs successfully:
[Test CSharp Build Job] $ ...\Jenkins\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MSBuild_2.0\MSBuild.SonarQube.Runner.exe end
SonarQube Scanner for MSBuild 2.0
Default properties file was found at ...\Documents\Jenkins\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MSBuild_2.0\SonarQube.Analysis.xml
Loading analysis properties from ...\Documents\Jenkins\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MSBuild_2.0\SonarQube.Analysis.xml
Post-processing started.
SonarQube Scanner for MSBuild End Step 1.1
No ProjectInfo.xml files were found. Possible causes:
1. The project has not been built - the end step was called right after the begin step, without a build step in between
2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
3. The build step has been launched from a different working folder
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
11:18:18.015 Creating a summary markdown file...
Post-processing failed. Exit code: 1
ERROR: Execution of SonarQube Scanner for MSBuild failed (exit code 1)
So in my Jenkins Configuration I have this:
Am I missing something to make this work?
Okay I figured it out
I forgot to add a /t:rebuild in between building with MSBuild and running the End Analysis command.

Microsoft.Lightswitch.Build.Tasks.Targets(168,5): application definition contains critical errors

I have a complex lightswitch application that was created using visual studio 2013, and then I upgrade it to using visual studio 2015. the solution was working fine, I even did a couple of deployment for it. Now I am trying to build it from a new machine and the build hangs (it never finishes). The output console is displaying an error: Microsoft.Lightswitch.Build.Tasks.Targets(168,5): application definition contains critical errors
I tried Google for a solution but could not find one that works in my case, I already checked the Link1 and this one Link2
When I cancel the build another similar error is displayed this is the output console:
------ Build started: Project: Agency Tool.Server, Configuration: Debug Any CPU ------
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\LightSwitch\v5.0\Microsoft.LightSwitch.Build.Tasks.targets(168,5): error : Application definition contains critical errors.
------ Build started: Project: Agency Tool.DesktopClient, Configuration: Debug Any CPU ------
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\LightSwitch\v5.0\Microsoft.LightSwitch.Build.Tasks.targets(217,5): error : Application definition contains critical errors.
------ Build started: Project: Agency Tool, Configuration: Debug Any CPU ------
The data necessary to complete this operation is not yet available. (Exception from HRESULT: 0x8000000A)
========== Build: 0 succeeded, 3 failed, 0 up-to-date, 0 skipped ==========
Resolved:
We noticed that in the main project properties--> extensions tab, Microsoft Lightswitch Extensions was not selected (I don't know what caused it to be unchecked, but I did not do it manually). However when we checked it the error disappeared.

SonarQube.Runner not compatible with C# plugin

I am trying to get the following Sonar C# plugin following the instructions here: http://docs.sonarqube.org/display/PLUG/C%23+Plugin
The C# plugin installed on the server is not compatible with the MSBuild.SonarQu
be.Runner.exe - either check the compatibility matrix or get the latest versions
for both.
Pre-processing failed. Exit code: 1"
when running step 6)a:
MSBuild.SonarQube.Runner.exe begin /k:"sonarqube_project_key"
/n:"sonarqube_project_name" /v:"sonarqube_project_version"
I have tried SonarQube versions 4.5.4 (LTS) and 5.1.1
Developer Command Prompt for VS2012
I installed java (oracle): jdk-8u51-windows-x64.exe
Microsoft (R) Build Engine version 4.0.30319.34209
Running on Windows server 2012
Any ideas on how to fix this?
thanks
From MrFox:
I've added a bounty to this question and am adding my questions on this issue here:
Do I need to make a SonarQube project or does "SonarQube_project_key" mean the visual studio project key I want SonarQube to scan.
Even though the term 'project' is used a lot I assume this relates to the open source definition of project. Not the visual studio definition that's part of a solution.
What exactly is the meaning of "sonarqube_project_version"? I've tried 6.5 (SonarQube version), 6.4.1 (SonarQubeC# plugin), 1.0.1 (MSBuild.SonarQube.Runner.exe version)
I've used the project key that's given as an example on the C# plugin website:
MSBuild.SonarQube.Runner.exe begin /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"Kadaster.Agris" /v:"1.0.1"
I've tried several permutations on these issues.
I would like to use the Analysis Bootstrapper for Visual Studio but can't find a download or explanation of how that could be done.
Edit: putting in the entire error message after request.
In text, this also include the command I'm using after the answers that have been given so far:
> D:\projects\agris\src>MSBuild.SonarQube.Runner.exe begin
> /k:"org.sonarqube:Kadas ter_Agris" /n:"Kadaster_Agris" /v:"0.1"
> Default properties file was found at
> D:\Software\MSBuild.SonarQube.Runner.1.0.1\ SonarQube.Analysis.xml
> Loading analysis properties from
> D:\Software\MSBuild.SonarQube.Runner.1.0.1\Sona rQube.Analysis.xml
> Pre-processing started. Preparing working directories... Checking for
> updates... The C# plugin installed on the SonarQube server is not
> compatible with the Sonar Qube analysis agent (i.e. the
> MSBuild.SonarQube.Runner.exe, or the build automat ion task). Either
> check the compatibility matrix or get the latest versions for both.
> Pre-processing failed. Exit code: 1
The first step is to do pre-processing:
> D:\projects\agris\src>D:\Software\sonar-scanner-msbuild-3.0.2.656\MSBuild.SonarQ
> ube.Runner.exe begin /k:"myCompanyHostedSonarQube:GMA_Kadaster_Agris"
> /n:"Kadas ter_Agris" /v:"0.1" SonarQube Scanner for MSBuild 3.0.2
> Default properties file was found at
> D:\Software\sonar-scanner-msbuild-3.0.2.656 \SonarQube.Analysis.xml
> Loading analysis properties from
> D:\Software\sonar-scanner-msbuild-3.0.2.656\Son arQube.Analysis.xml
> Pre-processing started. Preparing working directories... 09:08:16.861
> Updating build integration targets... 09:08:16.879 Fetching analysis
> configuration settings... 09:08:17.971 Generating rulesets...
> 09:08:17.993 Provisioning analyzer assemblies for cs... 09:08:17.994
> Installing required Roslyn analyzers... 09:08:18.507 Pre-processing
> succeeded.
Then the project must be rebuild.
Then tell SonarQube to end and send everything to the server, this last step fails:
> Done Building Project "D:\projects\agris\src\Kadaster.Agris.sln"
> (Rebuild targe t(s)).
>
>
> Build succeeded.
>
> "D:\projects\agris\src\Kadaster.Agris.sln" (Rebuild target) (1) ->
> "D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agris.Web.csproj.metaproj"
> ( Rebuild target) (13) ->
> "D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agris.Web.csproj"
> (Rebuild t arget) (14) -> (CoreCompile target) ->
> Controllers\OutputController.cs(48,30): warning CS0168: The variable
> 'ex' is declared but never used
> [D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agri s.Web.csproj]
> Controllers\OutputController.cs(80,30): warning CS0168: The variable
> 'ex' is declared but never used
> [D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agri s.Web.csproj]
> Controllers\OutputController.cs(166,30): warning CS0168: The variable
> 'ex' is declared but never used
> [D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agr is.Web.csproj]
>
> 3 Warning(s)
> 0 Error(s)
>
> Time Elapsed 00:00:08.91
>
> D:\projects\agris\src>D:\Software\sonar-scanner-msbuild-3.0.2.656\MSBuild.SonarQ
> ube.Runner.exe end SonarQube Scanner for MSBuild 3.0.2 Default
> properties file was found at
> D:\Software\sonar-scanner-msbuild-3.0.2.656 \SonarQube.Analysis.xml
> Loading analysis properties from
> D:\Software\sonar-scanner-msbuild-3.0.2.656\Son arQube.Analysis.xml
> Post-processing started. The SonarQube MSBuild integration failed:
> SonarQube was unable to collect the re quired information about your
> projects. Possible causes:
> 1. The project has not been built - the project must be built in between the b egin and end steps
> 2. An unsupported version of MSBuild has been used to build the project. Curre ntly MSBuild 14.0 upwards are supported
> 3. The begin, build or end steps have not all been launched from the same fold er Generation of the sonar-properties file failed. Unable to
> complete SonarQube ana lysis. 14:38:26.197 Creating a summary
> markdown file... 14:38:26.2 Post-processing failed. Exit code: 1
The three warnings are about unused exception variables.
Do I need to make a SonarQube project or does "SonarQube_project_key" mean the visual studio project key I want SonarQube to scan.
The key specified by /k: will be used as the unique key to identify your project on SonarQube server.
It can be anything, and it's really up to you.
A common choice for example is the name of the solution in Visual Studio.
The /n: parameter defines the display name to use on SonarQube.
The /v: parameter defines the version of your project that your analysis represents.
One of the main purposes of SonarQube is to track the code quality changes in the so-called leak period,
which is the time since the last release.
The metrics of the leak period reset when the version changes.
SonarQube doesn't assume the version of your project,
you tell it yourself explicitly.
Even though the term 'project' is used a lot I assume this relates to the open source definition of project. Not the visual studio definition that's part of a solution.
The term 'project' in SonarQube documentation refers to the representation on SonarQube. In Visual Studio terms, it corresponds to the 'solution'. You typically create one SonarQube project per Visual Studio solution.
This is a matter of how you want to look at your quality metrics.
It usually makes sense to aggregate the metrics of all Visual Studio projects under one dashboard in SonarQube.
I would like to use the Analysis Bootstrapper for Visual Studio but can't find a download or explanation of how that could be done.
That's obsolete. You should not need that anymore, at the time of this writing.
It seems you're using a very old version of Scanner for MSBuild.
You can download the latest version from here,
try with this one:
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild
However, note that current versions of Scanner for MSBuild require MSBuild version 14 or higher.
That implies that your project needs to be built with Visual Studio 2015 or higher.
If your project uses an older version,
you will have to migrate it.

Facing a problem when i am making a setup of Windows Service

i am trying to make a setup of windows service.but when i was building the setup the output is like that..
------ Build started: Project: TwitterService, Configuration: Debug Any CPU ------
TwitterService -> C:\Users\Globus-n2\Desktop\LatestTweetMati\TwitterService\bin\Debug\TwitterService.exe
------ Starting pre-build validation for project 'Setup' ------
------ Pre-build validation for project 'Setup' completed ------
------ Build started: Project: Setup, Configuration: Debug ------
Building file 'C:\Users\Globus-n2\Desktop\LatestTweetMati\Setup\Debug\Setup.msi'...
Packaging file 'TwitterService.exe.config'...
Packaging file 'GlobusLib.dll'...
Packaging file 'TwitterService.exe'...
Packaging file 'GlobusTwitterLib.dll'...
========== Build: 1 succeeded or up-to-date, 1 failed, 0 skipped ==========
setup is failed i am not getting any error.i have tried to make a new copy but still problem remain.i have tried to add those dll again but problem is not solved.can any one please help me to solve this problem.il really very thankful if any one try to solve this problem.
(I'm assuming here that you are using Visual Studio to build this project)
Try altering the output verbosity for the compilation. In Visual Studio, go to Tools -> Options -> Projects and Solutions -> Build and Run and change the value of the combo box labelled "MSBuild project build output verbosity". Setting it to Detailed or Diagnostic should give you more info in the output window, which will hopefully shed more light on what the problem might be.

Categories

Resources