How to disable code analysis in MSBuild target ClCompile? - visual-c++

When I build my projects via MSBuilds scripts, I obtain the following message during the work of ClCompile target: Running Code Analysis for C/C++…
Output of MSBuild looks like:
ClCompile:
....
Source1.cpp
Source2.cpp
Running Code Analysis for C/C++…
After changing <RunCodeAnalysis> property in build scripts to false:
<PropertyGroup>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
this just disabled running RunCodeAnalysis MSBuild target, but it does not affect running code analysis in ClCompile target - it seems it should be disabled somewhere else.
How can I disable code analysis during execution of ClCompile target?

<EnablePREfast> should be set up to false.
I have used the following code:
<PropertyGroup>
<EnablePREfast>false</EnablePREfast>
</PropertyGroup>
More info at CL Task

In Project Property page, goto Code Analysis (the last one on left tree). There you can disable Code analysis feature. In VC10+, you just need to de-select second check box. In earlier versions, you set third property to No.

Related

Xamarin.iOS versioning during build

I've been trying to get an automatic versioning system going for builds (mainly due to external crash analytics picking up each build as the same until I change the version manually). The format is simple, I take the CFBundleShortVersionString from the Info.plist, and append the current date and time (in yyyyMMddmmss format) as subversion.
The task I've put together for this:
<Project>
<Target Name="BeforeBuild">
<XmlPeek XmlInputPath="$(ProjectDir)Info.plist" Query="//dict/key[. = 'CFBundleShortVersionString']/following-sibling::string[1]">
<Output TaskParameter="Result" ItemName="VersionNumber" />
</XmlPeek>
<PropertyGroup>
<BuildNumber>$([System.DateTime]::Now.ToString(yyyyMMddmmss))</BuildNumber>
</PropertyGroup>
<XmlPoke XmlInputPath="$(ProjectDir)Info.plist" Query="//dict/key[. = 'CFBundleVersion']/following-sibling::string[1]" Value="$(VersionNumber).$(BuildNumber)" />
</Target>
</Project>
However it fails with the following error:
Target BeforeBuild:
[...]/[...].csproj(1069,5): error MSB3733: Input file "[...]/Info.plist" cannot be opened. For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
Done building target "BeforeBuild" in project "[...].csproj" -- FAILED.
What am I doing wrong? There's not much info about this error, at least not much that I could find and would help fixing it.

Service Fabric: packaging code error: missing required references

After updating SF I've got an issue that prevents using of SF totally, I'll try to put a problem in words without code.
Service fabric application AppName.SF consists of an AppName.SF.StatefulActor and AppName.SF.StatefulService. Both reference to class library called AppName.Core.
Case 1: StatefulActor not references StatefulService - package performs OK:
AppName.SF\pkg\Debug\AppName.SF.StatefulActor\Code has AppName.Core.dll
AppName.SF\pkg\Debug\AppName.SF.StatefulService\Code has AppName.Core.dll
each package Code folder has AppName.Core.dll. Deployment performs successfully.
Case 2: StatefulActor references StatefulService - package performs BAD:
AppName.SF\pkg\Debug\AppName.SF.StatefulActor\Code has AppName.Core.dll
AppName.SF\pkg\Debug\AppName.SF.StatefulService\Code has no(!) AppName.Core.dll
So I get a missing reference error if I try to deploy application in cluster. Issue appeared after SF updated to 1.4.87-preview.
Looks like you've found a bug - we are investigating. In the interim, it should work if you build using msbuild.
For a workaround add the following to your application project (.sfproj) file:
<Target Name="CopyExtraPackageFiles" AfterTargets="Package">
<Copy SourceFiles="..\AppName.Core\bin\$(Configuration)\AppName.Core.dll"
DestinationFolder="pkg\$(Configuration)\AppName.SF.StatefulService\Code" />
</Target>
This makes some assumptions about the location of your AppName.Core project. Adjust the path if necessary.
This will manually copy AppName.Core.dll to the appropriate location in the package where it is missing.
EDIT:
Or try this for a general purpose workaround instead of the above code snippet. Let me know if it works.
<Target Name="EnsureProjectReferencesAreConfigured" BeforeTargets="GetCopyToOutputDirectoryItems">
<MSBuild
Condition=" '#(ServiceProjectReference)' != '' "
Projects="#(ServiceProjectReference)"
Targets="AssignProjectConfiguration"
Properties="Configuration=$(Configuration);Platform=$(Platform)" />
</Target>

Conditional force build publisher CCnet fails

I have two build projects. lets call them project A and project A.pack. When I force build project A it asks me for Boolean parameter if I want to build project A.pack.
But I can't make in publishers block of project A a correct way to force build the project A.pack. I use conditional task but it doesn't work. In log file ccnet writes only that it fails on conditional task. What a usual way to do this in ccnet?
Update:
Sorry for my English. It's not my first language.
What I wanted to do is this:
In project A I added Boolean parameter:
<booleanParameter>
<name>ExampleParam</name>
<true name="Yes">1</true>
<false name="No">0</false>
<display>Example Param</display>
<default>No</default>
<required>false</required>
</booleanParameter>
And added conditional forcebuild in publishers like this:
<publishers>
<!-- some other tasks .. -->
<conditional>
<conditions>
<compareCondition>
<value1>${ExampleParam}</value1>
<value2>1</value2>
<evaluation>equal</evaluation>
</compareCondition>
</conditions>
<tasks>
<forcebuild>
<project>A.pack</project>
<serverUri>tcp://localhost:21235/CruiseManager.rem</serverUri>
</forcebuild>
</tasks>
</conditional>
</publishers>
When I press "force" it asks me for "Example Param", I check "Yes" and when it finishes building dashboard says that build was succesful but ForceBuildPublisher task failed.
There is no information in server log about why force build task failed.
It's CruiseControl.NET-1.6.7
Update 20150808:
I convinced my colleagues to update CCnet. In version 1.8.5 it's possible to do a conditional build like I wrote.
If the boolean parameter is true then write to a file that A.pack watches. A.pack builds if the file gets dirty. See Filesystem Source Control Block for use by A.pack in listening to the file made dirty by A.

Building vcxproj by MSBuild including logging to default log file specified in project or inherited from props file

When Visual C++ builds (vcxproj) file form Visual Studio or you build it by means devenv (building sln), then you get log form the build of the vcxproj in file specified by item BuildLog.Path.
Default value of this item is $(IntDir)\$(MSBuildProjectName).log
I’ve actually find this feature really useful for post build analysis per project.
I’d like to simulate this behavior by building just from msbuild.exe.
There are serious build automation reasons why I cannot use devenv now(as far as I’m aware I cannot build vcxproj by devenv without sln).
I've tried to resolve this problem by:
creating custom target that determines value of BuildLog.Path and returns it back
and then execute task Exec with msbuild commandline including argument that use filelogger to create log file
Problem is that it does not work!
There is an interesting thing that the default is specified by:
<ItemDefinitionGroup>
<BuildLog>
<Path>$(IntDir)\$(MSBuildProjectName).log</Path>
</BuildLog>
</ItemDefinitionGroup>
If I understood correctly this specifies metadata path for each BuildLog item.
By default there is no BuildLog Item (because there is no Include in vcxproj –for BuildLog Item).
Does anybody has solution for this problem or can explain how to solve it?
determine BuildLog.Path metadata or
build vcxproj file just by msbuild with logging file to log file specified in vcxproj or inherited from props file

How to make prestep system groovy script to interrupt jenkins build and set it to SUCCESS?

Say I have a maven2/3 project in jenkins/hudson and BEFORE I run some goals on a maven project configured in the correspoing config.xml file, I want to run a system groovy script (ref. system groovy plugin) during a prestep and interrupt the whole job and set it to SUCCESS if some condition is met (for example say I find something in the log file of the previous job). I DO NOT WANT MAVEN TO START EXECUTING THE GOALS.
I have tried
import hudson.model.*
def thr = Thread.currentThread()
def build = thr?.executable
build.executor.interrupt(hudson.model.Result.SUCCESS)
out.print "HELLO"
But nothing happens, and even "HELLO" is printed in log. But then the build gets ABORTED.
Parsing POMs
Discovered a new module ...
Modules changed, recalculating dependency graph
...
...jdk1.6.0_22/bin/java -Xmx512m -cp ...
<===[JENKINS REMOTING CAPACITY]===>Build was aborted
Thanks for your time.
I do not understand fully, what you want, since you described here some solution, not your exact problem. I know three plugins, which could be useful for your problem as well:
Fail the build plugin lets you set the result of the job, and stops further processing. Any status can be set including success.
Conditional build step plugin lets you define conditions for its child build steps. If the condition is met, the child(ren) will run.
m2 extra build steps - lets you run build steps before or after maven build in a maven job in jenkins. Note, that recently, this plugin is the part of the core jenkins.
So the basic idea is that you could add conditional build step a pre-build step in your job, and the child step could be one fail-the build instance. See the picture below:

Resources