czwartek, 21 listopada 2013

Change server name on which SharePoint is installed

It may be necessary e.g. when you create new VM with SharePoint as a copy of the existing one.
Use old stsadm tool to achieve the goal:

stsadm -o renameserver -oldservername <current name of the server> -newservername <new name for the server

poniedziałek, 18 listopada 2013

IIS configuration for debugging

ASP.NET  > .NET Compilation

Debug: TRUE
Default Language: C#

IIS > ASP

Enable Server-side Debugging: TRUE

Directly in web.config file

CallStack="true"
CustomErrors mode="Off"

Polskie znaki Ł i Ś

W pliku
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1045\FORM.js
zamienić
L_InsertCellLeftKey_TEXT=”L”   na   L_InsertCellLeftKey_TEXT=”false”
oraz
L_SplitCellKey_TEXT=”S”   na   L_SplitCellKey_TEXT=”false”

wtorek, 12 listopada 2013

Add and deploy solution with PowerShell

Add-SPSolution -LiteralPath "<path>\MySolution.wsp" | Out-Null
echo " > Adding MySolution..."
start-sleep -s 10
$sln = get-spsolution -identity MySolution.wsp
Install-SPSolution -Identity $sln -GACDeployment
while($sln.Deployed -eq $false) {
echo " > Deploying in progress..."
start-sleep -s 10
}
echo "MySolution is deployed."
Enable-SPFeature -Identity "MyFeatureName" -Url "<my site url>"

Need to know what exactly is your feature name? This command will display all web-scoped features:

Get-SPFeature | Where-Object { $_.Scope -eq "Web" } | Format-Table -Property DisplayName -AutoSize

Retrack solution with PowerShell

Set-ExecutionPolicy unrestricted
echo " "
echo "MySharepointSolution"
$sln = get-spsolution -identity MySharepointSolution.wsp
uninstall-spsolution -identity MySharepointSolution.wsp -confirm:$false
echo "Started solution retraction..." 
while($sln.JobExists) {
echo " > Working..."
start-sleep -s 10 
}
remove-spsolution -identity MySharepointSolution.wsp -confirm:$false
echo "Removed MySharepointSolution"
echo " "

środa, 30 października 2013

Make Visual Studio to add .dll to GAC after each build

Go to Project > Properties and enter the following into the Post-build event command line:
(on Windows Server 2012)
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe" /i
"$(TargetPath)" /f

(on Windows Server 2008)
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe" /i "$(TargetPath)" /f

Remember to:
  • run Visual Studio as Administrator
  • sign the assembly

wtorek, 22 października 2013

Replace columns in DataTable and by the way insert at specified position (code snippet)



DataTable table = GetSomeDataTable();

table.Columns.Add("NewNumber", typeof(int)).SetOrdinal(table.Columns["OldColumn1"].Ordinal);
table.Columns.Add("NewText", typeof(string)).SetOrdinal(table.Columns["OldColumn2"].Ordinal);

foreach (DataRow row in table.Rows)
{
  row["NewNumber"] = Transform1(row["OldColumn1"]);
  row["NewText"] = Transform2(row["OldColumn2"]);
}

table.Columns.Remove("OldColumn1");
table.Columns.Remove("OldColumn2");