Powered By Blogger

Sunday, September 14, 2014

StyleCop Integration with csproj and MSBuild

StyleCop Integration with csproj and MSBuild.

Step 1. Install StyleCope 4.7
Step 2: Update .csproj by adding 
                <Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.7\StyleCop.Targets" />
                ----------------
                </Project>
Step 3: Add the below Tag under   <PropertyGroup> to Treat Stylecop Warnings as Errors
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
                </PropertyGroup>
Step 4: By default, the "Merge with settings file found in parent folders" option is selected. StyleCop will continue searching above the current directory for additional parent settings files.


Step 5: Rather than merging with a settings file found within a parent directory, it is also possible to provide an explicit link to another settings file to merge with.


Step 6: Build csproj with MSBuild:


NOTE: If we are implementing Stylecop, we should edit all csproj before building the same. also there is no direct logging mechanism for StyleCop.
So Personally I will recommend FxCop instead of StyleCop.

SAP ABAP static code analysis using Fortify SCA

Description: ABAP is one of the many application-specific fourth-generation languages. It was originally the report language for SAP R/2, a platform that enabled large corporations to build mainframe business applications for materials management and financial and management accounting.

Our Problem: Whether Fortify supports ABAP?
Yes, Fortify Supports ABAP.
How we can achive and create Fortify Reports?
get .abap files to be scanned. If you are getting txt files, then change the extension to .abap.
Now apply below commandlines to generate frp.


"C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\bin\sourceanalyzer.exe" -b abapSample -clean

"C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\bin\sourceanalyzer.exe" -b abapSample myABAPfile.abap


"C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\bin\sourceanalyzer.exe" -b abapSample -scan -f myABAPfile.fpr

From .frp file, you can generate Report as xml and  pdf files.

"C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\bin\ReportGenerator.bat" -format xml -f "myABAPfile_Report.xml" -source  “myABAPfile.fpr"

"C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\bin\ReportGenerator.bat" -format pdf -f "myABAPfile_Security_Report.pdf" -source "myABAPfile.fpr"

"C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\bin\ReportGenerator.bat" -format pdf -template "C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\Core\config\reports\DeveloperWorkbook.xml" -f "myABAPfile_Developer_Workbook.pdf" -source "myABAPfile.fpr"

"C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\bin\ReportGenerator.bat" -format pdf -template "C:\Program Files\HP_Fortify\HP_Fortify_SCA_and_Apps_4.00\Core\config\reports\ScanReport.xml" -f "myABAPfile_Scan_Summary.pdf" -source "myABAPfile.fpr"

Wednesday, August 6, 2014

Customized Logs for msi

For writing customized Logging in default msi logs.
You can implement this using either a vb script or an installscript.
Below is a sample log which I created in between creating IIS WEBSITE and APP using APPCMD.

MSI (s) (A0:98) [11:02:47:417]: Hello, I'm your 32bit Impersonated custom action server.
Action start 11:02:47: callthis.
Custom Log: 7/11/2014 11:02:47 AM : Creating Site TestThisSite...
Custom Log: 7/11/2014 11:02:51 AM : Creating App WebUI under Site TestThisSite...
MSI (s) (A0:6C) [11:02:51:472]: Doing action: FindRelatedProducts
Action ended 11:02:51: callthis. Return value 0.

All you want to do is to include the below Function in your code.

InfoMessage “Here is my log”

Sub InfoMessage (MsgText)
            Const msiMessageTypeInfo = &H04000000
            Set oRec = session.Installer.createRecord(1)
            oRec.StringData(0) = "Custom Log: " & Now() & " : [1]"
            oRec.StringData(1) = MsgText
            Session.Message msiMessageTypeInfo, oRec
            Set oRec = Nothing
End Sub

Resolved: Cannot connect to WMI provider. You do not have permission or the server is unreachable

Open cmd as administrator:
Run MOF Compiler by passing below parameter as:

mofcomp "%programfiles%\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"


what is MOFcomp: 
The Managed Object Format (MOF) compiler parses a file containing MOF statements and adds the classes and class instances defined in the file to the WMI repository. MOF files are usually automatically compiled during the installation of the systems with which they are provided, but you can also compile MOF files by using this tool.

Microsoft SQL Server 2012       110
Microsoft SQL Server 2008 R2  100
Microsoft SQL Server 2008       100
Microsoft SQL Server 2005       90

Open services.msc
Restart Windows management Instrumentation WMI Service



Thursday, July 17, 2014

Passing Product Name as Parameter - InstallShield Basic MSI

Here is the step by step instruction for passing a product name from outside, i.e, command line. Since Product Name is a Private Property, we cannot pass this as a parameter from outside.

1.       Go to Property Manager, select ProductName Property and make Product Name property localizable by Clicking   [abc] symbol



2.       Create a new Public Property for assigning custom value.


  
3.       Create a Set Property Custom Action and Provide Proprty Name as  ProductName and Property Value as [MYPRODNAME]



  
4.       Build your msi.
5.       Install MSI by passing your custom Prod Name into the Public Property.







Wednesday, June 4, 2014

wait implementation using START in VBScript

We are much familiar with shell.Run in VBS for executing things in command. Also we have a Wait for the command to complete before continuing execution of the wsh script. Most of the time this flag may not works properly.
So I was struggling to get another option for the same and found a workaround by using START and its WAIT property to achieve my Task.
Here is the Demo:

Set objWshShell = CreateObject("WScript.Shell")
command = "%windir%\system32\cmd /c start /W c:\Windows\System32\inetsrv\appcmd.exe stop apppool /apppool.name:TestAppPool"
objWshShell.Run (command)

(The Demo code will Stop AppPool name TestAppPool)