Tuesday, January 21, 2014

People and group field is imported as Single line of text field when imported as spreadsheet

Issue: When we create a list using import a spreadsheet and if you have an people and group field in the spreadsheet, after import the people and group field may change as single line of text field.

Workaround: Create a people and group field in the same list where you have imported the list.Following PowerShell script will read the values from single line of text field and update in the value in people and group field. Make sure your AD user profile is similar to the source list/site.

Add-PSSnapin Microsoft.Sharepoint.Powershell
[System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$site = new-object Microsoft.SharePoint.SPSite("SiteURL”)
$web =  Get-SPWeb -Identity siteURL
$lista =$web.Lists["ListName"]
$items = $lista.items
foreach ($item in $items) {
  $user = $item["SingleTextColumnNameOfUserName"]
  write-host $useracc 
$useracc =  $web.EnsureUser( $user); 
$item["NewPeople&GroupFieldName"] = $useracc
write-host $useracc
$item.update()
}

$lista.update()


Wednesday, January 15, 2014

WSP Versioning


Versioning for WSP packages are possible, but we have to do it manually.

·     Embed the version number in the filename of the WSP.
·     Create a text file with the version information inside the package.

Solutions don’t have a version number included by default and it is recommended to add a version number to the solution name. With this approach we know which version of your solution is deployed.
For instance:
Use MyProjectSolution_v5000.10.1560.0.wsp as solution name for the build #1560.

AssemblyFileVersion
The AssemblyFileVersion is intended to uniquely identify a build of the individual assembly
Used for deployment. You can increase this number for every deployment. It is used by setup programs. Use it to mark assemblies that have the same AssemblyVersion, but are generated from different builds.
In Windows, it can be viewed in the file properties.
Example:
// Assembly mscorlib, Version 2.0.0.0
[assembly: AssemblyFileVersion("5000.10.1560.0")]
[assembly: AssemblyInformationalVersion("5000.10.1560.0")]
[assembly: AssemblyVersion("5000.10.0.0")]

AssemblyFileVersion is informational only.  Incrementing the version does not require a recompile of dependent assemblies.  It helps when browsing your bin folder to know which code version you have installed.
Assembly File Version

Code to read the current Assembly File Version
Assembly thisAssembly = Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(thisAssembly.Location);
Console.WriteLine(fvi.FileVersion);

PowerShell Command
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("Location of your executable").FileVersion


PowerShell script can be used to update the AssemblyFileVersion when the project is build.

Source: