ULS Viewer

A quick post today, just to say that there’s been an update to the ULS Viewer from Microsoft. A big improvement, main features are now:

  • Monitor all server logs in real time across the farm
  • Personalise the output and and colour code specific entries
  • Command line tool

All good and well worth downloading. Get it from here.

Posted in SharePoint | Leave a comment

Configuring SQL Server Whitepaper

I recently came across the following whitepaper for configuring SQL Server to get the best performance from it when used in a SharePoint environment.

Download it from here
Or view it from here

Lots of good information in it and well worth keeping to refer to when building SharePoint environments 🙂

Posted in SharePoint, SQL | Tagged , , | Leave a comment

Import Tag MSBuild Errors

Creating a SharePoint package is easy enough with Visual Studio but each time you restart it, the package location used previously is replaced with the default location of the current user’s Documents folder.

To save a few seconds from my life I decided to write a PowerShell script to build and package the solution, meaning I no longer have to specify the publish location whenever Visual Studio is restarted.

I’m using Visual Studio 2013 and SharePoint 2013

& "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe" "C:\Projects\TestProject\TestSolution.csproj" /t:rebuild;package
 
Write-Host "Copying TestSolution.wsp to Packages folder" -NoNewLine
Copy-Item -Confirm:$false "C:\Projects\TestProject\bin\Debug\TestSolution.wsp" C:\Packages\
Write-Host " - done."

The script shown has been simplified for this post and is easy enough to parametrise to allow you to specify different SharePoint projects to package.

Anyway, back to the main reason for this post.

After doing the above and running the script the following error was generated:

C:\Projects\TestProject\TestSolution.csproj(88,3): error MSB4019: The imported project “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
Continue reading

Posted in Visual Studio | Tagged , | 1 Comment

Create Site Collection with Content Database

A PowerShell related post today.

If you need to create a new site collection and ensure it uses a specific content database, this little script will get that done for you. No messing about in Central Administration disabling content databases and all that good stuff, just a simple script that gets the job done, hassle free.

$hostIP = $ENV:ComputerName
$hostURL = "http://$hostIP/sites/Site Collection Name"
$user = [Security.Principal.WindowsIdentity]::GetCurrent().Name
$dbServer = "$hostIP"
$contentDbName = "Your_Content_Db_Name"
$webAppName = "SharePoint - 80"
$lcid = 1033
$templateName = "STS#0"
$siteName = "Site Collection Name"
 
function Add-Site {
	Write-Host ("Creating new ComplianceSP site '", $siteName, "' at ", $hostURL -join "") -NoNewline
	$newSite = New-SPSite $hostURL -OwnerAlias $user -name $siteName -Template $templateName -Language $lcid -ContentDatabase $contentDbName
	$newSite.RootWeb.CreateDefaultAssociatedGroups($newSite.Owner, $null, $null)
	Write-Host " - Done." -ForegroundColor Green
}
 
function Add-ContentDatabase {
	$contentDatabase = Get-SPContentDatabase -WebApplication $webAppName | Where { $_.Name -eq $contentDbName }
	if ($contentDatabase -eq $null) {
		Write-Host ("Creating new content database '", $contentDbName, "' in '", $dbServer, "' for web application '", $webAppName, "'" -join "") -NoNewline
		New-SPContentDatabase -Name $contentDbName -DatabaseServer $dbServer -WebApplication $webAppName -MaxSiteCount 1 -WarningSiteCount 0 -Confirm:$false
		Write-Host " - Done." -ForegroundColor Green
	}
	else {
		Write-Host ("Content database '", $contentDbName, "' in '", $dbServer, "' associated with web application '", $webAppName, "' already exists." -join "") -NoNewline
	}
}
 
try {
	Add-ContentDatabase
	Add-Site
}
catch {
	Write-Host ""
	Write-Host "Error : " $Error[0] -ForegroundColor Red
	throw
	Exit 1
}

Lets walk through the code.
Continue reading

Posted in SharePoint | Tagged , | Leave a comment

Slow Query Duration

When working with custom code that manipulates lists that contain a large number of fields, the ULS logs will likely be littered with the following entries:

A large block of literal text was sent to sql. This can result in blocking in sql and excessive memory use on the front end. Verify that no binary parameters are being passed as literals, and consider breaking up batches into smaller components. If this request is for a SharePoint list or list item, you may be able to resolve this by reducing the number of fields.

followed by:
Slow Query Duration: [time in milliseconds]

then:
Slow Query StackTrace-Managed: [complete stack trace]

Note: This one’s important as you can look at the stack and identify the exact area of code that initiates the slow query log entries.

and finally:
SqlCommand: [SQL statement responsible for the log entry]
Continue reading

Posted in SharePoint | Tagged , | Leave a comment