you can use MSBuild for this purpose. This is how I do it for my projects:
So from powershell, you could call it like this:
.\MSBuild MyProject.proj /target:package /p:Configuration=Release
EDIT 25/06: Worked for James with the /target:publish
Note: You may need to specify the location of MSBuild as a variable, this can be found under C:\Windows\Microsoft.Net\Framework\
versionNumber\
In that case it'd become:
$msbuild = "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\msbuild.exe"
& $msbuild MyProject.proj /target:package /p:Configuration=Release
Notice the &
instead of the .\
this tells powershell to execute the variable (which in this case is an exe).
Also, further to your problem of not really knowing how to do it. I use a build language called PSake which is a PowerShell based build language which may be of use to you. It's pretty useful: https://github.com/psake/psake
Hope this helps.