how do I output my code to a single file? - vb.net

I need to dump all of my code for my project into a single text file. Is this possible in Visual Studio 2010? I haven't been able to find any options for this in VS. Is there a third party program that can do it? Every search I've done just turns up "how to print from VB", but does not address printing my actual code. Even if I have to do it module by module, that would be acceptable, but copying and pasting is a bit much.
Just FYI, I'm not talking about printing output from my program. I'm talking about printing the program itself.
Thanks.

This can be done outside of visual studio. Start a command prompt, cd to your project directory and:
type *.vb >filecontent.txt
If you have multiple project folders, you'll need to do this for each one as the type command doesn't have a /s subfolder type of parameter.
Alternatively, you could create a batch file that changes to each folder and performs the type command to output the file contents.

Related

How to avoid long paths in code built with CMake

I am using CMake to link and build my C++ project, and in said project I am using the fstream library to read from a file. However, when passing the path of the file to my code, I am forced to use a long string such as "../../../../folder/folder/folder/file" to properly reference which file I want opened. I presume this is because my .exe that CMake creates is buried deep, "far" away from my source code, which is why I would have to backtrack so much.
I am wondering if there is something I could put in my CMakeLists.txt to potentially allow for the shortening of this inclusion path.
To save myself some time I have not included my file structure as of now, but if it is needed in order for a solution to be formed I certainly can edit and add it in. I do not necessarily need a case-specific solution, rather just a generalized method in which I could go about doing this.
It looks like CMake doesn't provide such functionality , CMake doesn't do much with execution of your application.
So, For solution you have following
can either create a shell script to copy the file into the desired location which can be picked by the executable and shell script can be run while make process
pass it as a commandline argument to your c++ executable.
create a macro with this location and use this macro in the source file : - CMake can help you in this
Using add_compile_definitions( ...)

Visual Studio 2010 solution - how copy common exe to two main projects?

Situation: An application, that is built into several variations, with different functionality enabled. Each variation has its own main project, with its own output "bin" folder. Call the variations A and B.
There are various common class libraries, which generate dlls. Those all get automatically copied to both output folders. This is working fine.
Now, add another project. It generates an exe, C.exe. It will be loaded as a separate process by the application. (It creates a NamedPipe, providing a ServiceContract via NetNamedPipedBinding.)
When there was only "A" (no "B"), I simply had A and C specify the same output folder.
But now there are TWO places that C needs to go.
For Debug build, must go to A/bin/Debug and B/bin/Debug. Similar for Release build.
The source language is VB, but an answer based on C# projects would almost certainly be adaptable to my situation.
I've written an answer by using XCopy in Post Build Events.
Looking for alternative answers.
Is there a way that is easier to maintain / not dependent on manually entering paths?
My concern is that as variants are added, or moved around, it is necessary to know about the Build Events and manually edit them.
Doing work for a company that is not great at keeping track of such details over the years.
Looking for a way that is less likely to break, or easier for a junior programmer to maintain.
In Project "C", Properties, Post Build Events, use xcopy to copy the .exe and corresponding .pdb. Do this for both the "Debug" configuration and the "Release" configuration of Project C.
(For VB, this is under Compile tab, "Build Events..." button at lower right.)
In project A's Properties, find what its output path is. in this case, the path specified was bin\x86\Debug\. xcopy needs to be told this path, relative to project A inside the solution; this becomes $(SolutionDir)\A\bin\x86\Debug\. The resulting lines, to copy both the exe and its pdb for debugging:
xcopy /y "$(ProjectDir)$(OutDir)*" "$(SolutionDir)\A\bin\x86\Debug\"
This copies ALL files in "C"s output folder to "A"s output folder.
Before adding this line, examine "C"s output folder. Are there any files in it that should not be copied to A? If so, can they be deleted? (And will they STAY deleted, when you rebuild "C"?) If not, you will need to specify more carefully the source files, in xcopy line. Or use multiple xcopy lines, to specify the individual files.
Note the "A", which is the main project being copied to.
Repeat that line for "B".
As more variants of main project are created, add a line for them as well.
If one project specifies a different output path, then the lines need to be correspondingly changed.

Getting batch variables

Hi there. I am busy with making kind of script in batch.
I need to insert into it kind of "Resume" function.
I know how to write variables into a file.
But is it possbile to get it back?
Is it possible to get variables from registry?
I found a nice BAT => EXE converter. It looks really professional if you run .exe in place of .bat. I would like the user to download .exe installer of my batch program, and install the real program. But is it possible to install it (place file of program) as .exe? I don't know much about .exe languages.
If I understand your questions correctly,
Do you want to read a variable that was previously written to a file back into the batch script? Yes, it is possible to read a file into a variable as long as you know the file's format.
Yes, it is possible to read keys and values from the registry using the reg command.
Once you convert a .bat script into an .exe you can distribute it however you like. Place it in a .exe installer, zip it in a archive.

Replace token in text file with content from another text file in MSBUILD

I have 2 MULTILINE text files, I want to combine them into a third file in an Msbuild script.
Ideally, I would have a token in one file, say %REPLACEME%, somewhere in the middle of that file, and I would want it replaced with the contents of the 2nd file (which contain multiple lines of text).
I want to do this in MSBUILD, although a Windows Shell solution would suffice, and so would the usage of some 3rd party utility (preferably small, and a single exe).
The solution is trivial if the content of the replacement text file is just one line .. but that is not the case.
Note that I want to AVOID using Powershell, I also want to avoid building my own MsBuild Tasks.
Thanks
You can use the MsBuild Community Tasks which have a RegexReplace task. I use it for my builds without any problem

Problem with dynamically generated C# files in msbuild

I have a source XML file that is used to create C# files that are then compiled as part of a project.
Currently I have a BeforeBuild target that runs my XML to C# converter.
The problem is that by the time the BeforeBuild step is run the old files appear to have been stored by the build system so the new files are ignored.
How can I get around this? It seems that Transforms would be the way but they are limited in what they can do.
I guess your "stored by the build system" can be translated as the ItemGroup containing the .cs files you wish to compile is generated when the msbuild file is read, as opposed to when your compile target is executed. You have several options:
<CreateItem> see CreateItem task
<Output> see Output element
I hope this helps.
Well we have something similar-ish here. We gen a .cs off an xml file using a .tt. Both files are part of a specific csproj. Going properties->BuildEvents on the csproj gives this little snippet in the Pre-build event command line:
del "$(ProjectDir)MyCsFile.cs"
copy /b /y "$(ProjectDir)\MyXmlFile.xml" "$(TargetDir)"
"$(ProjectDir)tt.bat" "$(ProjectDir)MyTemplateFile.tt"
No idea if that's of any use to you, I hope it might suffice as a last chance workaround.
I think you need to show us a little of your rule/build file. You should have a rule/dependency for the cs file that has the xml as the dependency.
I am not sure what you mean by "stored by the build system"
Check your rules carefully for errors/omissions.