How can I create a Sharepoint package (*.wsp) from command line - visual-studio

I have a number of SharePoint web part projects in a single solution. To deploy a web part, I am using the "Publish..." option from solution explorer in visual studio. Then use the stsadm.exe to deploy them on SharePoint server.
Is it possible to generate a *.wsp package from the command line?

You can use msbuild tool to generate wsp packages.
Below you can find example of cmd script:
set msbuild="C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
set config=Release
set outdir2=C:\out\
rd /S /Q "%outdir2%"
%msbuild% /p:Configuration=%config% /m "C:\Test\test.csproj" /t:Package /p:BasePackagePath=%outdir2%
for /F "tokens=*" %%i in ('dir /B /S "%outdir2%"') do if not %%~xi == .wsp del %%i

Related

Run Skype through batch file (WindowsApp)

I made a batch file to open Itunes because I found no other way to have permanent shrtcut with WindowsApp and it work. Here it is:
for /f "delims=" %%a in ('dir /b /ad /on "C:\Program Files\WindowsApps\AppleInc.iTunes_*"') do set ver=%%a
set "exec=C:\Program Files\WindowsApps\%ver%"
cd "%exec%"
iTunes.exe
However when I made it manually through Powershell, it opens another windows than the batch file. This isn't an issue but I want to know why.
At the opposite, with Skype, when I go in the Skype folder and I run Skype.exe manually it works but with the batch files, it does nothing. Here is the code:
for /f "delims=" %%a in ('dir /b /ad /on "C:\Program Files\WindowsApps\Microsoft.SkypeApp_*"') do set ver=%%a
set "exec=C:\Program Files\WindowsApps\%ver%\Skype"
cd "%exec%"
Skype.exe
I want the batch file to works as if I click on the Skype.exe file or run it manually
Thanks

execute exe from incomplete name in .bat

I wanna make a .bat for installing service, I use that
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe "ServiceName.exe"
But the "v4.0.30319" can be "v4.0.otherVersion" and I look for a way to execute anyway.
I searched a lot of but didn't find something who work and I'm really bad with bash.
Thanks.
Based upon your provided information, this idea retrieves the location you require from the registry:
#Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Set "Net4RegPath=HKLM\SOFTWARE\Microsoft\Net Framework Setup\NDP\v4"
Set "InstallUtil="
For /F "EOL=HTokens=2*" %%G In (
'%__AppDir__%reg.exe Query "%Net4RegPath%" /S /F "InstallPath" /V /E
2^>NUL^|%__AppDir__%find.exe "_SZ"')Do For /F "Delims=" %%I In (
'%__AppDir__%where.exe "%%~H\.":"InstallUtil.exe" 2^>NUL'
)Do Set "InstallUtil=%%I"
If Defined InstallUtil "%InstallUtil%" "ServiceName.exe"
Please note that this will not currently retrieve the appropriate file path if you're wanting to specifically identify the location of the x86 InstallUtil.exe file on an x64 OS. But as that is technically outside of the scope of your question at the time of answering, I'll leave that for you to implement if required.

TFS2015 Builds: Post-build steps fail in Visual Studio Build

I’m having difficulty with vNext builds. Visual Studio Build step.
My solution fails whenever the post build steps in the solution I'm building runs. It exits with code 1.
I think the command I fine, it works fine locally, and on the build server when visual studio is run as an administrator.
I think the build agent doesn’t have permission to write files. Is there any way this can be fixed? Or to have this build step run as administrator?
The post build command is below:
echo POST-BUILD: Building files and copying the components files into host/bin folder
$(ProjectDir)Builder\BuildRules.cmd $(ProjectDir) $(TargetDir) && (IF NOT EXIST $(SolutionDir)..\..\host\Host\bin mkdir $(SolutionDir)..\..\host\Host\bin) && xcopy /F /R /Y $(TargetDir)$(TargetFileName) $(SolutionDir)..\..\host\Host\bin && xcopy /F /R /Y $(TargetDir)Service*Validator1.xsl $(SolutionDir)..\..\host\Host\bin && xcopy /F /R /Y $(TargetDir)Service*Validator2.xsl $(SolutionDir)..\..\host\Host\bin && xcopy /F /R /Y $(TargetDir)Service*Validator3.xsl $(SolutionDir)..\..\host\Host\bin && xcopy /F /R /Y $(TargetDir)Service*Functions.xsl $(SolutionDir)..\..\host\Host\bin && IF "$(BuildUri)"=="" COPY $(SolutionDir)\$(SolutionName)\$(OutDir)\*.xsl $(SolutionDir)\$(SolutionName).UnitTests\bin\$(Configuration)\ /Y
Thank you for any help!

Why am I getting a syntax error with this CMD script?

I'm trying to write a simple CMD script to automate the build of my repo. Here is the script in its entirety:
#echo off
setlocal
goto main
:: Functions
:buildSubdir
pushd %1
for /f %%projectFile in ('dir /b /s project.json') do (
dnu restore "%%projectFile"
dnu build "%%projectFile"
dnu pack "%%projectFile"
)
popd
goto :EOF
:main
:: Check for dnu
where dnu > NUL 2>&1
if %ERRORLEVEL% NEQ 0 (
echo dnu wasn't found in your PATH! 1>&2
echo See http://docs.asp.net/en/latest/getting-started/installing-on-windows.html for instructions on installing the DNX toolchain on your PC. 1>&2
exit /b %ERRORLEVEL%
)
:: Do the actual work
cd %~dp0
call :buildSubdir src
call :buildSubdir test
Basically, what it does is try to find all the files named project.json in a few select directories (src and test), and execute dnu restore, dnu build, and dnu pack on them.
For some reason, I seem to be getting a syntax error on the line where I enter a for /f loop, saying something about %projectFile not being recognized. Here's a gist of the full output from my terminal when I remove the #echo off statement and re-run the script.
Can anyone tell me why this is happening, and what I can do to fix it? Thanks.
edit: Just changed it to this:
for /f %%p in ('dir /b /s project.json') do (
set projectFile=%%p
dnu restore "%projectFile%"
dnu build "%projectFile%"
dnu pack "%projectFile%"
)
Still doesn't seem to be working, although the error messages are different now. Here's a gist of the new output. (Note how %projectFile% is set to the empty string.)
for /f "delims=" %%p in ('dir /b /s /a-d project.json') do (
dnu restore "%%p"
dnu build "%%p"
dnu pack "%%p"
)
The directory name is assigned to %%p so since that's all you're using, you have no need to assign it further.
The delims= ensures that the entire line is assigned to %%p - otherwise, %%p will be assigned the first token using the default delimiter set, the practical outcome of which is to truncate the name at the first space.
See
for /?
from the prompt for docco.
The /a-d removes any directorynames from the dir output (just in case there is a directory name matching the mask supplied - small possibility though that might be)
If you'd wanted to manipulate the name in %%p rather than just use it as-is, you'd have needed to use either delayedexpansion or called another routine to do the manipulation. The basis of this characteristic is thedelayedexpansion trap- batch will substitute the *parse-time* value of any%var%it finds in a code-block (parenthesised series of statements) for%var% before executing, so since %projectFile% was undefined at the start of the for loop, batch will replace it with nothing which is its value at that time.
For documentation, see many, many articles here related to delayedexpansion or read the scant documentation in
set /?
With the For construct, you use letters as variables: a-z and A-Z (it is important to note that the letters are case-sensitive) in the For construct. There are a number of ways you can use FOR and I would start here - http://ss64.com/nt/for_f.html
You can also FOR /? to get help as needed.
I think you are looking for this:
#echo off
setlocal
goto main
:: Functions
:buildSubdir
pushd %1
for /f %%p in ('dir /b /s project.json') do (
dnu restore "%%p"
dnu build "%%p"
dnu pack "%%p"
)
popd
goto :EOF
:main
:: Check for dnu
where dnu > NUL 2>&1
if %ERRORLEVEL% NEQ 0 (
echo dnu wasn't found in your PATH! 1>&2
echo See http://docs.asp.net/en/latest/getting-started/installing-on-windows.html for instructions on installing the DNX toolchain on your PC. 1>&2
exit /b %ERRORLEVEL%
)
:: Do the actual work
cd %~dp0
call :buildSubdir src
call :buildSubdir test

How do i delete all browsing data from all browser via command line?

I created a batch script to delete all browsing data from all browser via command line.
But it fails and doesn't clear all data.
It only deletes all the chrome data.
IE and firefox data isnt being deleted.
This works fine
for chrome:
set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data
del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"
for firefox
set DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
it does not delete all data.
for IE
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
This is also not working.
Please help me.
i am using windows 8.1 IE 11.
Is any other way to do this easily.
via command line.
So i tried the commands for firefox and IE11 both work for me. Are you running the script as administrator?
I changed the firefox command abit see below:
set DataDir=%loaclappdata%\Mozilla\Firefox\Profiles
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
for /d %%x in (%appdata%\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
As an alternitive you could use CCleaner command-line the command below will run ccleaner and clean using your default settings then close the program.
Cd "C:\Program Files\CCleaner"
ccleaner.exe /Cleaner /AUTO
You will have to change this command depending on if you use 32bit or 64bit windows
Are you planing on using this on a network ?

Resources