I searched and found some ques as ** how to restart apache using nant script ** and tried similar code but got some message..i tried this code
<exec executable="${APACHE_HOME}/bin/httpd.exe">
<arg value="-k"/>
<arg value="restart"/>
</exec>
OUTPUT:
apache-restart:
[exec] [Tue Nov 15 19:58:18 2011] [error] (OS 2)The system cannot find the file specified. : No installed ser
vice named "Apache2.2".
[exec] Result: 2
And the reason for this is i guess Apache is not installed as a windows service.
I tried both but both have problems:
1) my cursor kept blinking and next statement echo was not reached.
<target name="test" depends="init">
<exec executable="${APACHE_HOME}/bin/httpd.exe">
</exec>
<echo message="hello "/>
</target>
OUTPUT:
test:
2)where is this taskkill file present ??
<target name="test" depends="init">
<exec executable="taskkill /im httpd.exe">
</exec>
<echo message="hello "/>
</target>
OUTPUT:
Execute failed: java.io.IOException: Cannot run progra
"taskkill \im httpd.exe": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
Well, install the service first with httpd.exe -k install
Or you can execute taskkill /im httpd.exe to kill apache and httpd.exe to start it again. You may want to add /f switch to taskkill also.
Related
I am trying to build automatically a golang project in a windows environment with travis and to package the .exe making use of msbuild and wix.
The very same configuration works with Github actions and therefore I believe that both the .wixproj and the wxs are correct and there is some issue with the configuration of msbuild in the travis installation, but I have no more clues.
Possibly the msbuild installed by travis does not include the required wix toolset, I tried to install them, however while creating the package the error persist
The error
C:\Users\travis\gopath\src\github.com\gallo-cedrone\nri-elasticsearch\pkg\windows\nri-amd64-installer\nri-installer.wixproj" (default target) (1) ->
C:\Users\travis\gopath\src\github.com\gallo-cedrone\nri-elasticsearch\pkg\windows\nri-amd64-installer\nri-installer.wixproj(34,5):
error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\WiX\v3.x\Wix.targets" was not found.
Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
.travis
...
- os: windows
env:
- MSBUILD_PATH="c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
before_script:
- powershell Install-WindowsFeature Net-Framework-Core
- cinst -y wixtoolset
script:
- export PATH=$MSBUILD_PATH:$PATH
- go test ./src/
- go build -v -o ./target/bin/windows_amd64/nri-elasticsearch.exe ./src/
- msbuild.exe -version
- cd ./pkg/windows/nri-amd64-installer/ ; pwd ; env ; msbuild.exe ./nri-installer.wixproj
...
travis job logs
I found a solution thanks to enter link description here
Basically I was installing the wixtools, however the installation folder was not the expected one by vs2017.
It can be fixed simply by changing:
<Import Project="$(WixTargetsPath)" />
with:
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
and removing the WixTargetsPath clouses contitions.
What controls the environment passed to webpack when invoking Publish triggers a build? Look at this:
1>------ Build started: Project: MeshCut, Configuration: Debug Any CPU ------
1>MeshCut -> D:\MeshCut\bin\Debug\netcoreapp2.1\MeshCut.dll
2>------ Publish started: Project: MeshCut, Configuration: Debug Any CPU ------
MeshCut -> D:\MeshCut\bin\Debug\netcoreapp2.1\MeshCut.dll
npm install
audited 11025 packages in 7.787s
found 0 vulnerabilities
node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod
Hash: dadea967a4be0fa40482
Version: webpack 4.22.0
. . .
Publish Succeeded.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
In the first line it is obviously a debug build but this line
node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod
is clearly passed env.prod which is making it impossible to find out why there is an error in production that doesn't occur when the server is run from the IDE.
I tried setting an environmnent variable ASPNETCORE_ENVIRONMENT to "Development" but this was not helpful, probably because this is a run-time thing.
Ultimately this is an msbuild thing. The combination of a pubxml file and the csproj file are the inputs to msbuild.
Within the csproj file env.prod is a literal. IF there were some way to make the this value depend on the build type (release/debug) the problem could be resolved.
There is another question inspired by fundamentally the same problem, but the asker is satisfied with discovering that he can control it by editing the csproj. This is not helpful for respecting release/debug.
It's an MSBUILD thing. That means look in the csproj file and sure enough we find this
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
and it is easy to find the culprits in the second and third Exec statements.
The question remaining is how to either conditionally specify a parameter value, or how to conditionally specify a completely different command-line.
This Microsoft documentation appears to describe how to do the second option, but msbuild didn't like my attempt to wrap the exec elements with choose and when elements and I could still use some help.
It's an MSBUILD thing. That means look in the csproj file and sure enough we find this
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
and it is easy to find the culprit in the second of the Exec statements.
Exec supports a Condition attribute. Fortunately elsewhere in the CSPROJ file one of the targets is already conditional on the exact condition we require. With a little copy/paste and tweaking, the code becomes...
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.dev"
Condition=" '$(Configuration)' == 'Debug' " />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.dev"
Condition=" '$(Configuration)' == 'Debug' " />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod"
Condition=" '$(Configuration)' == 'Release' " />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod"
Condition=" '$(Configuration)' == 'Release' " />
Am trying to run dotfuscator via an Exec task using MSBuild. It gives a msb3073 exited with code 1 , any ideas or suggestions on further troubleshooting appreciated.
Following is the command in the target file:
<Target>
<Exec Command="%22$(ObfuscatorExe)%22 /q /p=AppPath=%22$(TargetDir.TrimEnd('\'))%22,ObfuscatedDll=%22$(TargetFileName)%22,PackageDir=%22$(ModuleDir)%22 %22$(PathOfDotFuscatorXml)%22" />
</Target>
The command gets translated as below.
error MSB3073: The command ""C:\Program Files (x86)\PreEmptive Solutions\Dotfuscator Professional Edition Evaluation 4.35.0\dotfuscator.exe" /q /p=PluginPath="<dlloutputpath>",ObfuscatedDll="<dllname>",PackageDir="<packageDir>" "<path to dotfuscator.xml>"" exited with code 1.
I have a feeling the extra quotes at the start and the end is causing this problem , because if i try to run this command on the dotfuscator command line , i am able to get the command working.
Additionally the MSBuild build output is set to diagnostic.
I tried to build kotlin compiler in Raspberrypi2 on Ubuntu Mate 15.10
When I execute ant -f update_dependencies.xml and during building, error occured below.
override-version:
[echo] Requested URL https://teamcity.jetbrains.com/guestAuth/app/rest/builds/?locator=buildType:IntelliJMarkdownParser_Build,status:SUCCESS,tag:forKotlin,count:1
[echo] Build Number: 3174 - Kotlin 1.0.0-beta-5160 Build Id: 662124
[get] Getting: https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:662124/artifacts/content/markdown_jar/markdown.jar
[get] To: /home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-4584/dependencies/markdown.jar
[get] Not modified - so not downloaded
[exec] Exception in thread "main" java.lang.reflect.InvocationTargetException
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[exec] at java.lang.reflect.Method.invoke(Method.java:497)
[exec] at org.jetbrains.kotlin.preloading.Preloader.run(Preloader.java:73)
[exec] at org.jetbrains.kotlin.preloading.Preloader.main(Preloader.java:35)
[exec] Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, /tmp/libjansi-32-2155791272664213050.so: /tmp/libjansi-32-2155791272664213050.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)]
[exec] at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
[exec] at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
[exec] at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:37)
[exec] at org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer.<clinit>(PlainTextMessageRenderer.java:35)
[exec] at org.jetbrains.kotlin.cli.common.messages.MessageRenderer.<clinit>(MessageRenderer.java:29)
[exec] at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:57)
[exec] at org.jetbrains.kotlin.cli.common.CLICompiler.doMainNoExit(CLICompiler.java:240)
[exec] at org.jetbrains.kotlin.cli.common.CLICompiler.doMain(CLICompiler.java:231)
[exec] at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:246)
[exec] at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
[exec] ... 6 more
I installed libjansi-java and libjansi-native-java but it doesn't work.
Is any idea solve this problem?
I updated soruce code to build-1.0.0-beta-5569 and added <arg value="-Dkotlin.colors.enabled=false"/> like belows:
--- a/update_dependencies.xml
+++ b/update_dependencies.xml
## -368,6 +368,7 ##
<macrodef name="build-protobuf-java-lite">
<sequential>
<exec executable="dependencies/bootstrap-compiler/Kotlin/kotlinc/bin/${kotlinc.executable.path}" failonerror="true">
+ <arg value="-Dkotlin.colors.enabled=false"/>
<arg value="-script"/>
<arg value="generators/infrastructure/build-protobuf-lite.kts"/>
<arg value="${basedir}/ideaSDK/lib/protobuf-2.5.0.jar"/>
## -419,6 +420,7 ##
<delete dir="${markdown.dir}" failonerror="false"/>
<unzip src="dependencies/download/markdown-sources.zip" dest="dependencies"/>
<exec executable="dependencies/bootstrap-compiler/Kotlin/kotlinc/bin/${kotlinc.executable.path}" failonerror="true">
+ <arg value="-Dkotlin.colors.enabled=false"/>
<arg value="${markdown.dir}/src"/>
<arg value="-d"/>
<arg value="${markdown.dir}/out"/>
## -874,6 +876,7 ##
<echo message="URL: ${override.version.url} Version: ${override.version.build.number}"/>
<exec executable="dependencies/bootstrap-compiler/Kotlin/kotlinc/bin/${kotlinc.executable.path}" failonerror="false">
+ <arg value="-Dkotlin.colors.enbled=false"/>
<arg value="-cp"/>
<arg value="dependencies/bootstrap-compiler/Kotlin/kotlinc/lib/kotlin-compiler.jar"/>
<arg value="-script"/>
After finsiehd update_dependencies.xml, I executed ant -f build.xml and got following errors:
runner:
[echo] Cleaning /home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/dist/classes/runner
[mkdir] Created dir: /home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/dist/classes/runner
[kotlinc] Compiling [/home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/compiler/cli/cli-runner/src] => [/home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/dist/classes/runner]
BUILD FAILED
/home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/build.xml:441: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jetbrains.kotlin.ant.KotlinCompilerBaseTask.execute(KotlinCompilerBaseTask.kt:92)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:853)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, /tmp/libjansi-32-7100610475620258495.so: /tmp/libjansi-32-7100610475620258495.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)]
at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:37)
at org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer.<clinit>(PlainTextMessageRenderer.java:35)
at org.jetbrains.kotlin.cli.common.messages.MessageRenderer.<clinit>(MessageRenderer.java:29)
at org.jetbrains.kotlin.cli.common.CLICompiler.execFullPathsInMessages(CLICompiler.java:69)
... 22 more
Total time: 1 minute 3 seconds
I fixed build.xml like this:
diff --git a/build.xml b/build.xml
index 38f751c..7bcfeb1 100644
--- a/build.xml
+++ b/build.xml
## -299,6 +299,7 ##
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true"
maxmemory="${max.heap.size.for.forked.jvm}">
+ <sysproperty key="kotlin.colors.enabled" value="true"/>
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
</classpath>
## -468,6 +469,7 ##
failonerror="true"
fork="true"
maxmemory="${max.heap.size.for.forked.jvm}">
+ <sysproperty key="kotlin.colors.enabled" value="true"/>
<assertions>
<enable/>
</assertions>
## -732,6 +734,7 ##
<pathconvert property="src.line" refid="src.dirset" pathsep=" "/>
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
+ <sysproperty key="kotlin.colors.enabled" value="true"/>
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
</classpath>
## -771,6 +774,7 ##
<sequential>
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
+ <sysproperty key="kotlin.colors.enabled" value="true"/>
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
</classpath>
and then, I execute ant build.
ant -f build.xml -Dkotlin.colors.enabled=false.
I'm not good at ant. So, I can not sure that this is correct syntax. but build was started and I got same error.
BUILD FAILED
/home/kyungkoo/Downloads/kotlin-build-1.0.0-beta-5569/build.xml:442: java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi in java.library.path, /tmp/libjansi-32-7323034426853998701.so: /tmp/libjansi-32-7323034426853998701.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)]
at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:37)
at org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer.<clinit>(PlainTextMessageRenderer.java:35)
Looks like jansi native libraries are missing for Raspberry Pi. I'm not sure if they should be available, but you can safely disable them while building Kotlin because Kotlin compiler only uses jansi to output colored diagnostic messages to the terminal. To disable the use of colors (and hence jansi), try applying this patch in the root of the Kotlin project:
diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java
index e83309d..d4755e6 100644
--- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java
+++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/messages/PlainTextMessageRenderer.java
## -32,9 +32,7 ## import static org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
public abstract class PlainTextMessageRenderer implements MessageRenderer {
// AnsiConsole doesn't check isatty() for stderr (see https://github.com/fusesource/jansi/pull/35).
// TODO: investigate why ANSI escape codes on Windows only work in REPL for some reason
- private static final boolean COLOR_ENABLED =
- !SystemInfo.isWindows &&
- CLibrary.isatty(CLibrary.STDERR_FILENO) != 0;
+ private static final boolean COLOR_ENABLED = false;
private static final String LINE_SEPARATOR = LineSeparator.getSystemLineSeparator().getSeparatorString();
I was just trying to get Kotlin to work on my Raspberry Pi as well. I followed the link above - https://youtrack.jetbrains.com/issue/KT-10605 - from IRus. From that I saw that it does check a property to disable color, fortunately.
So, at least for now until the change is propagated, you can do the following:
kotlinc -Dkotlin.colors.enabled=false
which will then skip the part that tries to load a non-ARM shared library. At least it works for me to get the REPL running.
Another way I found is to set the env variable JAVA_TOOL_OPTIONS like so:
export JAVA_TOOL_OPTIONS="-Dkotlin.colors.enabled=false"
this will be picked up by the java vm and then you do not need it on every command line (though it does spit out an annoying 'Picked up message' every time.
The command line Kotlin compiler developed by jetbrains can be installed as a snap package in all currently supported versions of Ubuntu. To install it, open the terminal and type:
sudo snap install kotlin --classic
Available tools:
kotlinc
kotlinc-jvm
kotlinc-js
kotlin-dce-js
This is my first dive into MSBuild so I'm feeling pretty lost.
The end goal is to run an executable which will output a file, and we want the output of the build to be that file. In this build there is no VS project what so ever.
The build is being run by TFS build services.
At this point all I'm trying to do is generate a file and have it copied to the drop folder.
Here is the contents of my .proj file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build">
<Message Text="Output Dir: $(OutDir)" />
<MakeDir Directories="$(OutDir)" />
<Exec Command='dir /s > \\ANetworkPath\dir.txt
dir /s > $(OutDir)Dir2.txt'/>
</Target>
</Project>
The first command of writing dir to the network path succeeds, however it doesn't show the existence of $(OutDir). So I thought I would try to create it with MakeDir. When the second dir command executes it errors because the path doesn't exist.
TFS is running MSBuild with the following command
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\Scratch\Test Build\Sources\user\Test\Build.proj" /m:1 /fl /p:SkipInvalidConfigurations=true /p:OutDir="C:\Builds\1\Scratch\Test Build\Binaries\\" /p:VCBuildOverride="C:\Builds\1\Scratch\Test Build\Sources\user\Test\Build.proj.vsprops" /dl:WorkflowCentralLogger,"C:\Program Files\Microsoft Team Foundation Server 2010\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;BuildUri=vstfs:///Build/Build/111;InformationNodeId=6570;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;TFSUrl=http://tfshost:8080/tfs/Test%20Collection;"*WorkflowForwardingLogger,"C:\Program Files\Microsoft Team Foundation Server 2010\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;"
The only output is in the file written on the network:
Directory of C:\Builds\1\Scratch\Test Build\Sources\user\Test
09/17/2010 10:53 AM <DIR> .
09/17/2010 10:53 AM <DIR> ..
09/17/2010 10:53 AM <DIR> A Directory
09/17/2010 10:53 AM 0 Test.log
09/17/2010 10:53 AM 453 Test.proj
09/17/2010 10:53 AM 201 Test.proj.vsprops
3 File(s) 654 bytes
Directory of C:\Builds\1\Scratch\Test Build\Sources\user\Test\A Directory
09/17/2010 10:53 AM <DIR> .
09/17/2010 10:53 AM <DIR> ..
09/17/2010 10:53 AM 9 A File.txt
09/17/2010 10:53 AM 15 Another File.txt
2 File(s) 24 bytes
Total Files Listed:
5 File(s) 678 bytes
5 Dir(s) 40,243,372,032 bytes free
Here is the build log:
Build started 9/17/2010 12:05:29 PM.
Project "C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj" on node 1 (default targets).
Build:
Output Dir: C:\Builds\1\Scratch\Test Build\Binaries\
dir /s > C:\Builds\1\Scratch\Test Build\Binaries\Dir2.txt
The system cannot find the path specified.
C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj(24,3): error MSB3073: The command "dir /s > C:\Builds\1\Scratch\Test Build\Binaries\Dir2.txt" exited with code 1.
Done Building Project "C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj" (default targets) -- FAILED.
Build FAILED.
"C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj" (default target) (1) ->
(Build target) ->
C:\Builds\1\Scratch\Test Build\Sources\user\Test\Test.proj(24,3): error MSB3073: The command "dir /s > C:\Builds\1\Scratch\Test Build\Binaries\Dir2.txt" exited with code 1.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.14
Am I going about this completely wrong?
Your code works fine in my computer.
However : you should instantiate OutDir property either by passing it in Command-Line invokation :
c:\WINDOWS\Microsoft.NET\Framework\v4.0\MSBuild.exe test.proj /p:OutDir=MyNewDir
or with a PropertyGroup element :
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutDir>MyNewDir</OutDir>
</PropertyGroup>
<Target Name="Build">
<Message Text="Output Dir: $(OutDir)" />
<MakeDir Directories="$(OutDir)" />
<Exec Command='dir /s > \\ANetworkPath\dir.txt
dir /s > "$(OutDir)\Dir2.txt"'/>
</Target>
</Project>
Notice the \ added in the dir command.
EDIT : I get it : you have a space in your output path. The command dir /s > my path\Dir2.txt is not gonna work unless you encapsulate the path with quotes. Try the following commands in the dos shell :
mkdir C:\Builds\1\Scratch\Test Build\Binaries\
mkdir "C:\Builds\1\Scratch\Test Build\Binaries\"
You will notice the difference (the first line creates two directories one C:\Builds\1\Scratch\Test and one .\Build\Binaries). I edited my code above to add quotes.
This will also work.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build">
<Exec Command='dir /s > Dir2.txt'/>
<Copy SourceFiles='Dir2.txt' DestinationFolder='$(OutDir)' />
</Target>
</Project>