I have a strange issue with msbuild and git, i have a target in msbuild where i create a file that contains commits to git, but the target is not working when msbuild is running it...
I toke a snippet from the task to show what i am doing:
<GitLogFormat>%25H:%25an:%25cd:%25B</GitLogFormat>
<GitLogPath>gitlog.xml</GitLogPath>
<Exec
Command='"$(GitRunner)" log --full-history --pretty=format:"$(GitLogFormat)" > $(GitLogPath)'
WorkingDirectory="$(GlobalRootPath)"
</Exec>
This will output the command:
"C:\Program Files (x86)\Git\bin\git.exe" log --full-history --pretty=format:"%H:%an:%cd:%B" > gitlog.xml
If i execute this from a commandline (not msbuild) then the output of the gitlog file will look like this:
35b833f0133cee6bd749be6cc4dbb40c15ab1ff2:rewso:Sun Sep 14 12:16:51 2014 +0200:Main release_ContractManagement was commited local v: 0.17.2
0ca16d0c60768879cb876c1da8e9fb2e76ef6074:rewso:Sun Sep 14 11:29:16 2014 +0200:Main release_ContractManagement was commited local v: 0.16.2
fe14af5547f458dab069aa862c304e03136f0a94:rewso:Sun Sep 14 01:08:15 2014 +0200:Main release_ContractManagement was commited local v: 0.15.2
But if i do this from msbuild the output of the gitlog file will be:
an:B
an:B
an:B
How can i get the same output when i use msbuild??
The % character needs to be escaped twice. Had the same problem once and I don't remember why exactly it is needed twice; it might have something to do with Exec or underlying cmd treating % as character used for environment variables.
Anyway, this should do it:
<PropertyGroup>
<GitLogFormat>%25%25H:%25%25an:%25%25cd:%25%25B</GitLogFormat>
</PropertyGroup>
Related
I thought liquibase is looking for that file in the liquibases' folder I placed in my linux' /opt folder.
That folder (/opt/liquibase) is in profile.d already so I can call liquibase anywhere.
And yet, when I type "liquibase update", it gives the following output on the terminal:
Starting Liquibase at Sun, 15 Sep 2019 23:00:43 CEST (version 3.8.0 built at 2019-08-15T20:38:06Z)
Liquibase Community 3.8.0 by Datical
Errors:
The option --url is required.
The option --changeLogFile is required.
It makes me wonder why url and changeLogFile are missing, because in /opt/liquibase/liquibase.properties, I got the following lines:
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/luquibase?autoReconnect=true&useSSL=false
username: zend
password: zend
changeLogFile: ~/html/zend/sql/changelog.xml
What do I do wrong here?
This is as-designed behavior. It is expected that people using liquibase will use it on multiple projects, so it looks for the liquibase.properties file in the current directory, which may not be the directory where the liquibase shell script lives.
We are currently calling the runner like this:
D:\BuildTools\MSBSonarQubeRunner-1.0.2\MSBuild.SonarQube.Runner.exe begin /k:"someKey" /n:"someName" /v:"someVersion" /d:sonar.resharper.cs.reportPath="K:\somePath\resharper.xml"
We want to have the output of sonar in K:\.sonarqube
We tried to use the command line arg /d:sonar.working.directory=K:\\.sonarqube but that didn't work. We also tried setting the working directory in the SonarQube.Analysis.xml like this: <Property Name="sonar.working.directory">K:\.sonarqube\</Property>
That didn't work too ...
We need to have it in a top directory, because the sonar runner throws an PathTooLongException (out path is 286 characters long).
Thank you for your help
It is not possible to change the working directory of the SonarQube Scanner for MSBuild.
You can however launch the build from another folder, but all 3 steps (begin, msbuild and end) must be launched from that folder:
k:
D:\BuildTools\MSBSonarQubeRunner-1.0.2\MSBuild.SonarQube.Runner.exe begin ....
msbuild /t:rebuild c:\whereever\your\sources\are\Solution.sln
D:\BuildTools\MSBSonarQubeRunner-1.0.2\MSBuild.SonarQube.Runner.exe end
I'm trying out SonarQube using the new MSBuild SonarQube Runner v1.0.
The Pre-processing works fine
E:\sonarQube\MSBuild.SonarQube.Runner-1.0>MSBuild.SonarQube.Runner.exe begin /k:"MyKey" /n:"MyProject" /v:"1.0"
.......
Process returned exit code 0
Pre-processing succeeded.
Then MSBuild works
E:\sonarQube\WebApplication2013>msbuild
Microsoft (R) Build Engine version 4.0.30319.34209
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.
........
Done Building Project "E:\sonarQube\WebApplication2013\WebApplication2013.sln" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.51
While end command following error gets generated
E:\sonarQube\MSBuild.SonarQube.Runner-1.0>MSBuild.SonarQube.Runner.exe end
.......
6:35:10 PM Generating SonarQube project properties file to E:\sonarQube\MSBuild.SonarQube.Runner-1.0\.sonarqube\out\sonar-project.properties
6:35:10 PM No ProjectInfo.xml files were found. Check that the analysis targets are referenced by the MSBuild projects being built.
6:35:10 PM Writing processing summary to E:\sonarQube\MSBuild.SonarQube.Runner-1.0\.sonarqube\out\ProjectInfo.log
6:35:10 PM Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
6:35:10 PM Creating a summary markdown file...
Process returned exit code 1
Post-processing failed. Exit code: 1
Required your assistance
As pointed out by duncanpMS's comment, you need to run all the 3 commands from the folder of the project you want to analyze.
Here is how:
cd E:\sonarQube\WebApplication2013
E:\sonarQube\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe begin /k:"MyKey" /n:"MyProject" /v:"1.0"
msbuild /t:rebuild
E:\sonarQube\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe end
You can add E:\sonarQube\MSBuild.SonarQube.Runner-1.0 to your %PATH% environment variable so that you can simply type MSBuild.SonarQube.Runner.exe instead of the full path from the command line when you analyze projects.
You need msbuild version 12 or version 14. If you have VS2013 , Msbuild version 12 comes with it. If you have VS2015, Msbuild version 14 comes with it.
If you don't have , download Microsoft Build Tools 2013 or 2015.
Run Msbuild -version to verify the version before running the 3 commands sequentially in the solution folder.
I have a .sql file which contain create script for 20 tables.I am running this through ant.
the Ant Script is
<target name="CompleteDBRollCreate" >
<sql classpath="D:\lib\ojdbc14.jar" driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:#12326:1521:orcl"
userid="scott" password="tiger"
src="D:\dropalltables.sql" />
</target>
but there is no logging in ant so I can't know if the SQL file was executed correctly. Can any one please suggest how to do logging into a separate localfile/on the ant console. I just want to know where I need to change the .sql file or the ant script.
There is logging in ant. Check out Running Apache Ant - Command Line:
-logfile use given file for log
-logfile will give you jdbc jdbc exceptions and all the noise around that, which can be useful, but I would also recommend spooling in the sql file as well as it looks like you are going to have multiple statements in the script. So I'd say you should use the -logfile option and also alter your script to spool any ORA errors you might encounter if you have multiple statements.
spool test.out
create table foo (testCol varchar2(2));
drop table foo;
spool off
I'm running a command using the msbuild "Exec" task. However I do not want the stdio output generated from the command to appear in the console, is there anyway to suppress it?
Maybe something along the lines of using the Exec task to call "cmd.exe" with my command exe is a target , and then using ">" to redirect the output somewhere else. (However I'm unable to get this solution to work).
i.e.
<Exec Command="cmd.exe sqlplus.exe $(someCommandSpecificSettings) < test.txt"/>
Any suggestions to get my example to work or alternatives?
The best way to suppress Standard Output and Standard Error Output from Exec tasks or any task that inherits from ToolTask is to lower the importance of the output. That way if you're debugging your build, these output won't be completely hidden because you're redirecting them to nul.
<Exec Command="sqlplus.exe" StandardOutputImportance="low" StandardErrorImportance="low"/>
Just for your information :
( >) redirect the output to the file you specified after (overwritten if needed)
append the output to the file you specified after (not overwritten)
< redirect the standard INPUT to your command (basically pass the content of the file after to your command)
With your code, you create (once) and replace each time a test.txt file. Instead of using a filename, you can use NUL that means redirect to nowhere. This will not create the file (which could be huge in some case) :
<Exec Command="cmd.exe /c sqlplus.exe $(someCommandSpecificSettings) > NUL"/>
If you want to redirect the errors as well, you use 2> like :
<Exec Command="cmd.exe /c sqlplus.exe $(someCommandSpecificSettings) > NUL 2>errors.txt"/>
Also note that you can redirect the stderr to stdout using 2>&1, thus
> NUL 2>&1
will redirect everything to nowhere.
Hope this clarifies your mind ^^
Ok, figured it out ... cmd.exe required a /c argument to work for what I wanted i.e.:
Also, it should be > instead of <
<Exec Command="cmd.exe /c sqlplus.exe $(someCommandSpecificSettings) > test.txt"/>
Try this:
<Exec Command="cmd.exe sqlplus.exe $(someCommandSpecificSettings) < test.txt >nul"/>