Xpath error due to miscorrected paths - c#

When i start to debug application i am getting this error Can any one give me the solution
Error 1 The command "xcopy "F:\asoadmin_ML_view\leaf\Console\Bin\Debug\Console.*" "F:\leafPRODUCT\Bin" /f /e /y /i
xcopy "F:\leafPRODUCT..\voyagerhtml\Operations Sentinel Console Help*.chm" "F:\leafPRODUCT\Help" /f /e /y /i
" exited with code 4.

According to this, error code 4 means either you do not have enough memory to perform debugging, or (much more likely) you have invalid syntax. The answer to this thread suggests placing double quotes around your entire path.

Your build process likely has a pre/post build step associated with it that is executing the XCopy commands. Error code 4 implies either insufficient disk space to perform the copy, or a syntax error in the command.
To edit your project's pre/post build steps, right click on your project, then select Properties -> Build Events. To diagnose these commands, try running them from the command line after you build your project.

Maybe the user with which you try to execute the 'xcopy' doesn't have enough permissions (according to this thread: http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/5c4a55e2-243a-427f-800d-39b42c9e860e).

Related

Try to Automate the Build Process for C# Solution through user click

I tried to establish a process through a click button where I can do following activities.
Objective
Download the latest code from SVN.
Build 2 set of Codes to create dlls and exe-
(a)Web application in Release mode
(b)Standalone application in debug mode
Then Replace some values of keys inside config files.
Then Place them to particular location.
Steps followed so far
Created demo.bat file which will build exe and dlls for Standalone as shown below
REM * ============================Starting Setup for Standalone======================================
SET Folder= C:\Automating\Application\Source\StandaloneApp\
cd %Folder%App1
msbuild /property:Configuration=Debug App1.csproj /t:clean /t:build
cd %Folder%App2
msbuild /property:Configuration=Debug App2.csproj /t:clean /t:build
del /F /S /Q /A %Folder%Setup\*.*
XCOPY %Folder%App1\bin\Debug\*.* %Folder%Setup\*.* /S /Y /F /Q
XCOPY %Folder%App2\bin\Debug\*.* %Folder%Setup\*.* /S /Y /F /Q
Created Another bat file demo1.bat to change command prompt to VS2010 cmd prompt
%comspec% /k ""c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
%comspec% /k ""C:\Automating\BuildAuto\BuildAutomation\demo.bat""
Created one more cmd files to download from svn
TortoiseProc.exe /command:export /URL:[URL path] /Path:"C:/Automating/Demo"
Finally A web application where from user can click button to download as per svnExport.bat and build the downloaded code as per demo1.bat.
protected void Button2_Click(object sender, EventArgs e) {
ProcessStartInfo psi = new ProcessStartInfo(#"C:\AutomatingPOC\BuildAuto\BuildAutomation\demo1.bat");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = false;
psi.CreateNoWindow = false;
Process.Start(psi);
}
Downloading event is working correctly, but build is not working. I need help on how can I build the code
Why reinventing the wheel? Use available tools, such as TeamCity and msbuild (there are plenty other alternatives as well).
I found Eugene made a really nice introduction here.
People spent man-years developing and polishing build automation tools. If I were you, I would stop right there and had a look around.
if you set psi.UserShellExecute to false, then you will need to specify that the command to execute is actually "cmd.exe" and that the batch file is an argument. You'll also have to manages the delay between the time that the request is made and the time the build is actually completed.
automating a task like this can be done easily with Auto Hot Key. also to automatically download you can use the start command and the type of browser of your choice IE Firefox iexplore chrome ~ then you can automate the download. but do note that with some websites page number may change IE.This address has a specified page code:
Try to Automate the Build Process for C# Solution through user click
so instead of putting the regular address in the batch or what ever you chose to use you can put in
https://stackoverflow.com/questions/********
allowing it to find the information
or you can use a mouse/key-board recorder to automate the task.

XCopy failing during build but not from command line?

I have a console program that outputs its exe & dlls to a specified directory.
As a post build event I am trying to copy everything in that directory to another directory.
My xcopy command works from command prompt but fails in VS2010? How can this be?
I am testing it by going to the project folder and executing the following in command prompt. (it is the output from VS2010)
In my post-build event:
xcopy "$(OutDir)*.*" "$(TargetDir)..\..\Foo\Bar\" /s /y /i
From command prompt I am executing the following which works.
xcopy "..\..\..\..\MyDir\baz\zip\*.*" "c:\1\2\3\MyDir\baz\zip\..\..\Foo\Bar\" /s /y /i
Sorry about the directory names.
End result should be two directories with the same files in them:
c:\1\2\3\MyDir\baz\zip
c:\1\2\3\MyDir\foo\bar
The target path is relative to the output directory.
When its executed as part of the build it gives an exit code 4
Initialization error occurred. There is not enough memory or disk
space, or you entered an invalid drive name or invalid syntax on the
command line.
Where am I going wrong?
Got it,
I changed the xcopy command in my post build event to:
xcopy "$(TargetDir)*.*" "$(TargetDir)..\..\Foo\Bar\" /s /y /i
The executed result being:
xcopy "c:\1\2\3\MyDir\baz\zip\*.*" "c:\1\2\3\MyDir\baz\zip\..\..\Foo\Bar\" /s /y /i
Which VS2010 much preferred, I guess you can't use a relative path without a base path.
Why you don'y call batch file which will run xcopy for required files source to destination?
call "$(SolutionDir)scripts\copyifnewer.bat"
With copyifnewer.bat looking like this:
IF NOT EXIST <destination> md <destination>
XCOPY /Y <file> <destination>

Create Batch file for iexpress

I am trying to use iexpress to run my batch file which will execute the 2 exe & 1 msi files for me. when i try to do it manually, it works.
following is the code in my batch file.
Start /wait %CD%\1.exe /q
Start /wait %CD%\2.exe /q
msiexec.exe /i "%CD%\3.msi"
but this doesn't seem to be working when i create an exe file from iexpress.
Reference
Above mentioned article has some code(to copy files to temp folder) & but i am not able to understand the syntax.
MKDIR %Tmp%\<UNIQUE PRODUCT NAME>
XCOPY . %Tmp%\<UNIQUE PRODUCT NAME> /S /E /Y
%Tmp%\<UNIQUE PRODUCT NAME>\setup.exe
The problem is that, as you can see from your screenshot, the batch file is being executed by command.com, not cmd.exe. (If you don't specify an interpreter, IExpress uses command.com. Ouch.) So there are no variables like %cd% or %~dp0.
You likely don't need them anyhow. But you do need to execute your batch file explicitly in IExpress like:
cmd.exe /c file.bat
so that it uses a modern command interpreter.
The second bit of code in your question makes the files persistent (ie they won't be deleted after the IExpress archive terminates) by xcopying them to a different directory.
Here is what it means:
1) Creates a directory(MKDIR) with name of "UNIQUE PRODUCT NAME" in the path stored in %TMP% Environment Variable, which normally points to: C:\DOCUME~1\yourusername\LOCALS~1\Temp
MKDIR %Tmp%\<UNIQUE PRODUCT NAME>
2) Then copy recursively all installation files from current folder into the new folder created before.
XCOPY arguments:
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
XCOPY . %Tmp%\<UNIQUE PRODUCT NAME> /S /E /Y
3) Finally execute the application from the new location
%Tmp%\\setup.exe
Hope this helps
Try replacing %CD% with %~dp0
Assuming that 1.exe is in the same folder as your batch script.
Your %CD% is not working. Please be sure that CMD extensions are enabled (type CMD /x to enable and CMD /y to disable) then expand the %CD% with this code
SET CURDIR=%CD%
Start /wait "%CURDIR%\1.exe" /q
Start /wait "%CURDIR%\2.exe" /q
msiexec.exe /i "%CURDIR%\3.msi"
And I'm not sure that you can start an exe from that location (APPDATA) for security reasons.
Thanks a lot for this forum discussion.Finally i could able to compile all msi files and executables in an one .exe file.
Complete procedure as follows create a batch file
echo on
SET CURDIR=%CD%
msiexec.exe /i "%CURDIR%\1.msi"
"%CURDIR%\3.EXE"
"%CURDIR%\setup.exe"
echo off
You can arrange any number of exe files or msi files as you wish and save the batch file as yourfile.bat.
Now the tricky part is before you proceed to Iexpress, convert the batch file to exe with the software provided by http://www.f2ko.de/programs.php?pid=b2e
Now when you run the program keep the 'Invisible Application' checked to hide the command prompt.You can also encrypt your exe with the password.'Delete at Exit' is optional as the temporary folder will be automatically deleted when the execution of files completed.
Once you successfully compile the batch file,execute the .exe file created.
Bingo!! you'll not see the command prompt window and your applications start executing sequentially.
Begin your Iexpress tool and Add all your files present in the batch file(except batch file).On the ‘Install Program to Launch’ screen, leave the Post Install Command blank and find the following in the Install Program dropdown:'demo.exe'and proceed further to create your complete bunch of single package. Cheers!!

What does this funnelweb command mean in visual studio? and why did it exit with 4?

In visual studio on the post build event command line I have the following:
xcopy $(TargetPath) $(SolutionDir)FunnelWeb.Web\bin\Extensions\ /Y
and its creating the error:
Error 1 The command "xcopy C:\Users\Exitos\Desktop\FunnelWeb-2.0.2.572-source\src\FunnelWeb.Extensions.MetaWeblog\bin\Debug\FunnelWeb.Extensions.MetaWeblog.dll
C:\Users\Exitos\Desktop\FunnelWeb-2.0.2.572-source\src\FunnelWeb.Web\bin\Extensions\
/Y
xcopy C:\Users\Exitos\Desktop\FunnelWeb-2.0.2.572-source\src\FunnelWeb.Extensions.MetaWeblog\bin\Debug\CookComputing.XmlRpcV2.dll
C:\Users\Exitos\Desktop\FunnelWeb-2.0.2.572-source\src\FunnelWeb.Web\bin\Extensions\
/Y" exited with code 4. FunnelWeb.Extensions.MetaWeblog
Im confused as to where the $(TargetPath) and $(SolutionDir) are set, and why this error happened?
xcopy exit codes can be found here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true
I suspect the problem is that you need double quotes around your paths:
xcopy "$(TargetPath)" "$(SolutionDir)FunnelWeb.Web\bin\Extensions" /Y
Becouse of spaces inside your path.
When you open a .sln, $(SolutionDir) is the directory where it came from. If you
want to change it, move the root folder for your .sln file.
Hope it helps.

Run batch script before Debugging

I want to run a batch script every time before starting program for debugging.
For the build events, such functionality is realized using pre-build event, post-build event.
For actual debugging, I could not find any pre-Debug, post-Debug events.
How to realize this scenario?
I am using VS2008, .net framework 3.5, c# application.
I am opposed to idea of creating some extra lines of code within the application that would fire-up external batch file.
I realise you wished to avoid additional code, but in your Main function you could use Debugger.IsAttached() to kick off your work for you.
For example:
if (Debugger.IsAttached)
{
System.Diagnostics.Process.Start(#"C:\myBatchFile.bat");
}
You can use a VS macro.
I had the same issue and this is the best I came with so far
Dim MustUpdateDB As Boolean
Private Sub DebuggerEvents_OnEnterRunMode(ByVal Reason As EnvDTE.dbgEventReason) Handles DebuggerEvents.OnEnterRunMode
If (MustUpdateDB) Then
MsgBox("Start debug operation", MsgBoxStyle.OkOnly, "TITLE")
REM DO WHATEVER COMMAND HERE
REM System.Diagnostics.Process.Start("C:\listfiles.bat")
MustUpdateDB = False
End If
End Sub
Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
MsgBox("Build Done", MsgBoxStyle.OkOnly, "Title")
MustUpdateDB = True
End Sub
There is a pretty good explanation on how to add event handlers to a macro
here
The only issue I have so far is to figure out how to get the currently debugged application active directory
A basic solution that worked for me (in VS 2017) was to create a batch file that does the command(s) that should run before debugging, and also include as the last line some parameters to be passed via command-line, such as this:
rem Place the command(s) you need here:
xcopy pristine.file changed.file
rem Now process passed commands - a few extra placeholders shouldn't hurt anything, to
rem allow for some extra command-line parameters
%1 %2 %3 %4 %5 %6 %7
Now in the debugging properties, set the 'Command' to your batch file, and for 'Command Arguments' include $(TargetPath) as the first argument, followed by any arguments your program uses or needs:
$(TargetPath) my command args
YMMV, but for my simple needs this seems to be working well.
if $(ConfigurationName) == Debug mkdir c:\mydir
You should check out... How to run Visual Studio post-build events for debug build only
So, you have a .bat file that you want to run via the pre-build event?
Try to specify full path to your batch file in the pre-build event command e.g.
cmd /c C:\Path\to\foo.bat
or
cmd C:\windows\system32\cmd.exe /c C:\Path\to\foo.bat

Categories