Is there a way to search for all the solution files (.sln) in a given directory, and build them all?
You can do this by using batch or PowerShell to find the fileset and then drive the commandline invocation of the build process.
You can use this batch file:
for /F %%a in ('dir *.sln /s/b') do msbuild "%%a"
Related
I'm running the following nuget command to extract a dll from a nuget package located in C:\utils and extract it to C:\dll.
nuget.exe install -o C:\dll TDS.AppLogger -source C:\utils
The dll gets extracted to C:\dll\TDS.AppLogger.1.0.0\lib\net452. I'm not sure why it's creating the TDS.AppLogger.1.0.0\lib\net452 subfolders.
Is there an option in the command that I can include which would not create the subfolders?
Is there an option in the command that I can include which would not create the subfolders?
I am afraid not. That because this command is not used to extract a dll from a nuget package, but extract NuGet package from .nupkg files. See Install command for NuGet CLI reference, this command similar to restore in that it only adds packages to disk in a hierarchical layout. And you can check the command about NuGet CLI reference, there is no option in the command to extract a dll from a nuget package.
To resolve this issue, you can consider use a .bat file to extract a dll, below is a sample code:
#echo off
echo Extracting all dlls from nugets to folder C:\dll
REM %mypath% is where the batch file is located
set mypath=%~dp0
set temppath=%~dp0temp\
set dllpath=C:\dll\
mkdir %dllpath%
rem traverse all nupkg files
pushd %mypath%
for /r %%a in (*.nupkg) do (
echo \- Processing %%~nxa
REM unzip nuget to %temppath% folder.
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('%%a', '%temppath%'); }
REM Copy all dlls
pushd %temppath%
for /r %%b in (*.dll) do (
echo \- Found %%~nxb
COPY "%%b" "%dllpath%%%~nxb"
)
popd
REM Delete Temp folder
rd /s /q %temppath%"
)
popd
pause
The source code from here.
Just put the bat file under the folder: C:\utils
#Leo-MSFT - Thanks for your response.
I ended up using MSBuild and adding the Unzip task to unzip the nuget package and extract it's contents to a destination location.
<Unzip ZipFileName="$(ReleasePath)\exe\utils\AppLogger.1.0.0.nupkg" TargetDirectory="$(ReleasePath)\exe\dll\" />
I just created the following batch file which saves all my lyx documents as tex files:
cd /d "D:\"
:: if the "for"-command is executed from the command line, just use "%" rather than "%%"
for /R %%g in (*.lyx) do "C:\Program Files (x86)\LyX 2.1\bin\lyx.exe" --force-overwrite --export pdflatex "%%g"
The problem is now that instead of the *.lyx files the batch uses the *.lyx~ files which are as far as I know some kind of backup files and don't contain the latest content.
How can I modify the batch file such that it takes the *lyx files rather than the *.lyx~ files?
Any suggestion would be great help.
Best :-)
PS: If I type this code in the command line (without using the batch), everything is fine.
#Edit1: added tokens option. Now it works in subdirs with spaces.
Modify your for loop to:
for /F "tokens=*" %%g in ('dir /b /s *.lyx') do if "%%~xg" equ ".lyx" (
"C:\Program Files (x86)\LyX 2.1\bin\lyx.exe" --force-overwrite --export pdflatex "%%g"
)
Another solution would be to use forfiles.
As for the 3rd comment, I think it does both but it does the .lyx~ at the end.
To see the output of a batch file simply launch it from a cmd window.
Lets say I have a project solution, I want to copy the contents of bin/Release folder after the build into another folder named "Deploy"
Source: D:\Solution\bin\Release
Destination: D:\Destinationfolder\bin\deploy
the macros are as follows
TargetDir : D:\Solution\bin\Release
ProjectDir: D:\Solution
I have tried this
xcopy /? $(TargetDir) $(ProjectDir)\..\Bin\Deploy /R /Y /S
This is not working. Am I doing anything wrong? Is there any other way to do this?
Remove the /? from the xcopy command, and add quotes around paths. The .. will take the $(ProjectDir) path back to D:, so the Destinationfolder should also be added.
So: xcopy "$(TargetDir)" "$(ProjectDir)\..\Destinationfolder\Bin\Deploy" /R /Y /S
I would suggest you to create a Publish Profile. If you want to build the project to a desired folder you can simply right click on the project and click Publish.
strange 1 here..
have a solution with multiple projects in (mvc2 application, class library etc).
the solution will not build in debug mode anymore. 1 if the projects isnt building its DLL anymore (although it creates reference dll's in the bin\debug folder).
this gives me the error: Metadata file 'C:[solution]\bin\Debug[myprojectname].dll' could not be found.
if i put the build into release, all my dll's build and solution correctly loads.
any idea why this is happening?
thanks
Check Build - Configuration Manager.
For each project in your solution you can check if it should be build and some more things.
I found that sometimes a project just got unchecked so it wont build,....
If you have lots of Metadata errors in build output, there is usually one compilation error way at the bottom of the list. Do you have any compiler directives in your code (like #ifdef DEBUG that would be causing problems?
Sometimes VS gets confused and I have to go manually clean the bin folders for it to recompile. I usually create a batch file and put it in the root of my solution to do this for me.
Clean.bat:
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G"
I run this whenever VS starts misbehaving. If that doesn't work then it's time for a reboot.
I have a DLL project for Visual Studio 2005 that has "XML documetation file" turned on.
Whenever I do an incremental build, during post-build event execution there is no XML documentation file in the output directory.
If I pause the build during post-build event (using sleep utility from GnuWin32 CoreUtils), I can see the file in the output directory with a name like vs5BB5.tmp. But this file is not renamed to MyLib.xml until post-build event (and "AfterBuild" target, as I have some customizations there) are finished.
For a clean build in Studio and for MSBuild started from a command line everything works as expected - XML documentation file is created before post-build events.
Why this happens, and how do I fix incremental builds?
Was just having the same issue. This is a known problem with Visual Studio and incremental builds. See this post on microsoft connect.
I solved it with a conditional xcopy like the one below:
if exist "$(TargetDir)$(TargetName).xml" xcopy $(TargetDir)$(TargetName).xml $(ProjectDir)......\bin\ /C /I /R /Y
SF
Just having this problem myself....
what I found is that the xml file is named a .tmp file, so you can copy this tmp file to where you want, its just a bit of a "messy" work around.
I'm also quite tempted to write myself a command line tool thats called something like :-
WaitForThenCopy <source path> <target path> <milliseconds to wait>
only problem is it would have to be non blocking and you wouldn't know if it worked or not.
I'm using a simple batch file to do the copying instead of the default copy command that detects the tmp file and copies/renames this instead.
REM There is a bug in VS where the xml documentation is written to a tmp file
REM during incremental builds, preventing access during post-build events.
REM See http://connect.microsoft.com/VisualStudio/feedback/details/470485/strange-file-not-found-error-xml-documentation-file-renamed-during-incremental-build
REM As a work around for following script tries to catch this situation and copys/remanes
REM this tmp-file instead.
REM .SYNOPSIS
REM CopyXmlDocumentation "X:\path\to\source.xml" "Y:\target\dir"
if exist "%~1%" (
REM if the file exists, copy it as-is
copy /Y "%~1" "%~2"
) else (
REM else we try to copy the .tmp file and rename it to the desired target name
REM we assume that the tmp file is named "vsXXXX.tmp" where XXXX is an arbitrary string
copy /Y "%~d1\%~p1\vs*.tmp" "%~2\%~n1%~x1"
)