Hi all I have an external project and I want to build it in the main project for that
I'm using pre-build commands.I want to use multi commands for copying aspx pages and
ascx usercontrols to sercontrol folder.
When I use one command it works but when I write both lines it returns error code 1
and not builds.I tried to put comma between two commands but not worked.
copy $(SolutionDir)\WebUI.PlugIn.UrlUsage\*.aspx $(ProjectDir)\Pages\Report
copy $(SolutionDir)\WebUI.PlugIn.UrlUsage\*.ascx $(ProjectDir)\UserControls\Report
Can you say how to run mlti commands in pre-build events of vs.net?
A good technique is look at the error produced by Visual Studio when the prebuild fails. Copy that error to the command line and run it. That should allow you to see what the issue is more clearly.
In this case it might be something simple like not having quotes round stuff.
It shouldn't make a difference but you don't need the first \ after the $(SolutionDir).
Related
I'm using TextTransform.exe to generate multiple C++ files. Since the tool is not supported directly within Visual Studio for C++ projects I call it by command line (inspired by T4 Generating C++ Code).
In order to generate multiple files I use https://github.com/areve/Entity-Framework-T4-Templates/blob/master/src/dev/MultiOutput.tt that's why I don't need the standard output which is normal generated by the tool.
I call TextTransform.exe like:
"C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0\TextTransform.exe"
-out "<what to put here that NO file is generated?>"
C:\Test.tt
I'm using Microsoft Windows. Maybe there is a "hack" to provide any kind of special char which would be accepted by the program but it wouldn't be possible to actually create a file out of it.
Is there a possibility to provide any command which generates NO file when I execute this command?
Update
As mentioned by #ImprobabilityCast using NUL is a way to go. It's not producing any file but the custom build where I run the tt file with is failing with the message:
Performing Custom Build Tools
CUSTOMBUILD : error : FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path.
I reach what I want but it's not so "nice" that the build action is failing.
Not sure why you don't want the files, but...
In linux we have a wonderful thing called /dev/null that is essentially an empty void just for things like this. I did a quick search, and Windows has it's own equivilent: NUL
Thus, the command you want is:
"C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0\
TextTransform.exe" -out NUL C:\Test.tt
No. The way text transformation was built was only thought to produce a single output file. Multi output was a logical evolution for T4 templates but Microsoft has not evolved it for years now.
The code that you're using (as am I) is basically a hack around that. It uses a very ugly way of using the EnvDTE to manipulate the project system that will probably end up not working one of these days when MS decides to rewrite that system (and one could argue that day is coming).
T4-editor, for example, has a slightly different way of achieving the same thing but you can see that the output still produces the "dummy file":
http://t4-editor.tangible-engineering.com/blog/how-to-generate-multiple-output-files-from-a-single-t4-template.html
I've found a satisfing solution for my problem. Since Microsoft Visual Studio allows for custom build tools to enter multiple lines I realized that I can delete the file generated by the TextTransform.exe I don't need.
So the command I put into "Command Line" contains two lines now:
"C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\14.0\TextTransform.exe" -out "%(DefiningProjectDirectory)$(TempOutputFile)" C:\Test.tt
DEL /F "%(DefiningProjectDirectory)$(TempOutputFile)"
The first line is the actual TextTransform call which produces me all the files I want including the output file I don't need but can't stop to be created.
The second line just deletes me the file I don't need.
This command expects a project variable calles "TempOutputFile". In this way I skip any typo's. For example:
<PropertyGroup Label="Globals">
<TempOutputFile>DoNotCheckin.h</TempOutputFile>
</PropertyGroup>
While trying to setup the Cap'n Proto compiler as a custom build tool in Visual Studio 2017, I came across a curious behavior, it only seems to work when called directly and not through a batch file.
What I first tried was, for each .capnp file, set the following Custom Build Tool settings:
Command line: "$(SolutionDir)run_capnpn.bat" compile -oc++ "%(FullPath)"
Description: Executing capnp.exe on %(Identity)...
Outputs: %(Identity).c++;%(Identity).h
I made the batch file because I wanted to avoid polluting my %PATH% with the capnp folder, this is what it contains:
#echo on
echo %*
SET PATH=%PATH%;C:\GitHub\capnproto\bin\c++\src\capnp\Debug
start /wait "" capnp.exe %*
exit /b %errorlevel%
However, with this setup the Custom Build Tool was only called on 1 of the 5 capnp files in my solution (all 5 files had exactly the same settings). I know this because only one pair of generated files appeared and only one message appeared in my build log.
Even weirder, if I compiled again it would do the next file, and on the following compile it would do another file. In all, it would take 5 compiles (one per file) before it considered everything to be fully built and stop calling the custom build tool.
After much trial and error and some help from other programmers on Discord, I tried adding capnp.exe to my path and call it directly (instead of going through the batch file) so for each capnp fil I changed the command line setting to:
capnp.exe compile -oc++ "%(FullPath)"
and now it all builds correctly. Is it possible to call a custom build tool through a batch file? and if so how?
I'm trying to do a checkout of a file using a prebuild step in visual studio 2012.
When I run the command verbatim on the command line it runs and checks out the file. When I try to use the same command as a prebuild step it exits with code 9009.
Do you really think it can't find the file in the context of the prebuild step? I even used macros vs. direct paths, put things in quotes, checked slash directions (/ vs ) but no luck.
My prebuild step is:
$(DevEnvDir)tf.exe checkout "$(SolutionDir)Includes\js\myFile.js"
I changed tf.exe to DevEnvDir thinking perhaps it couldn't "see" tf.exe, but this still exits with code 9009.
Thanks!
I figured out what it was:
I needed to have quotes on EVERYTHING including tf.exe (that's so annoying)
this doesn't work
$(DevEnvDir)tf.exe checkout "$(SolutionDir)Includes\js\myFile.js"
this does:
"$(DevEnvDir)tf.exe" checkout "$(SolutionDir)Includes\js\myFile.js"
I have a project, which use a .rules file to build some non-c++ sources. How to make MSBuild print diagnostic output from this tool? -- Precisely cerr stream.
(I silently presume, the M$ team have not reached that level of insanity, to give the custom building tools functionality without possibility to print errors from them.)
I've actually noticed you marked question with label visual-studio-2008. I guess it means your custom build tool processes non cpp files in vc2008 project? If so, I think it is not built by msbuild but with vcbuild.
In this case try to add echo on in front of command executed by custom tool.
Vcbuild creates batch files in %temp% that first line contains #echo off and then it is executed. So if you add echo on you should see complete output in output window including command line used for command execution.
I've read this discussion but despite different attempts, I get an error (it varies depending on my approach).
The compilation itself works fine. Double-clicking on the "publish.bat" files executes it just fine too. It's the combo in VS10 that breaks.
This is what I've tested.
$(OutDir)\publish.bat
"$(OutDir)\publish.bat"
$(OutDir)publish.bat
"$(OutDir)publish.bat"
call $(OutDir)\publish.bat
call "$(OutDir)\publish.bat"
call $(OutDir)publish.bat
call "$(OutDir)publish.bat"
What am I missing?
I had a similar problem that I was just able to fix. For me the simple call "$(SolutionDir)\Setup\CreateInstaller.bat" worked, but I kept getting a The command "call {solution directory}\Setup\CreateInstaller.bat" exited with code {code}. Turns out my batch file was expecting to be run from the directory in which it lived. So, check that all the commands in the batch file are not using relative directories or commands as these may break.
Also, are you sure the $(OutDir) macro is what you want? In VS2010 at least, that is just equal to bin\Debug or bin\Release depending on which version you're building in. It seems unlikely that you really want that directory. I expect what you want is $(SolutionDir) or perhaps even $(TargetDir).