I have a windows service executable in a separate visual studio project that I would like to start running during the post build event on a web forms project. I have added the executable to my web project as a linked file. I am trying to run a start command to boot up the windows service in the post build events command line, but I can't figure out how to get the file path of the executable from the linked file. Is this possible?
I ended up retrieving the file path from a powershell script and placing it in a custom macro to hold the file path in the .csproj file. I just run the powershell script pre build and the exe post build using the build events command line. A terrible hack, to be revisited another time.
Related
I am using VS Code on windows 10 and also code runner extension, everything was working fine till I used a workspace in a multi filed project, from there no file would to run through VS code automatically, I either have to use cmd or run it manually in the terminal.
I think the problem is that I used a workspace and it moved all my files to this workspace.
Now I can't even run any files that I created after this problem.
All the files names were changed to
file_name.py - Untitled (Workspace) - Visual Studio Code
How do I build and run a Xamarin.UWP application from the command line? I want it to be so that the app builds and runs the same way as the green run button in the Visual Studio 2019 GUI.
Additional notes:
I've tried opening the Visual Studio Developer Command Prompt and trying the following implementations.
msbuild -t:build "PATH_TO_PROJECT\SimTools.UWP.csproj"
Although when I run the executable that gets generated, it gives me this error:
as well as
Additionally, I've tried doing
msbuild -t:build "PATH_TO_PROJECT\SimTools.UWP.csproj" && msbuild -t:install "PATH_TO_PROJECT\SimTools.UWP.csproj"
And although it builds successfully, it says that there is no target for "install" and I do not know how to add that to the .csproj file as I've asked over at How do I add an "install" target to a Xamarin.UWP .csproj file?.
I have a Visual Studio 2019 CMake project and i need to run a postbuild script which copys a file (The file is not generated by the build process). What i did so far is add a custom command in CMake with
add_custom_command(TARGET testExec POST_BUILD COMMAND "../postbuild.bat")
The postbuild.bat would copy the file. This works great most of the time but when my build fails due to some compile error, the postbuild script won't be executed.
How can i run the postbuild script even if the build fails ? I know there is a similar question here but sadly no proper solution. If there is a way to configure a postbuild event directly inside a Visual Studio CMake project this would also be suitable, but it seems like this is not possible (because in a cmake project i don't have a project file).
Since The copied file is not generated by the build you can use PRE_BUILD. On Visual Studio Generators, it runs before any other rules are executed within the target.(https://cmake.org/cmake/help/latest/command/add_custom_command.html).
The other solution could be to use add_custom_command(OUTPUT as the file seems independent of the build.
I have written a NSIS script for my project, and I would like to automatically create the setup file when I build the project. How can I do this with Visual Studio? Is there a way to pass parameters to the script?
I mean, I would like VS to pass the Assembly Version to the script. Right now, I have to manually edit a line in the script
VIProductVersion 1.5.0.1
and I sometime forget to update it. Is there a way to automate the process?
You can create defines and/or execute script instructions by using the /D and /X makensis parameters
NSIS can also read files with !searchparse
There are two questions here.
Q1. Launch NSIS when building with Visual Studio?
A1. Make a Post-build event that runs makensis on the .nsi file:
"C:\Program Files (x86)\NSIS\makensis.exe" "$(ProjectDir)\NSISInstaller\Installer.nsi"
Q2. Pass the Assembly Version to the post build event?
A2. Answered here: Determine assembly version during a post-build event
Combined solution should be:
"C:\Program Files (x86)\NSIS\makensis.exe" "$(ProjectDir)\NSISInstaller\Installer.nsi" /DPRODUCT_VERSION=$(AssemblyVersion)
In VS 2008 and VS 2010, one can easily create a solution and modify the "Solution Configuration". We can choose what configuration each project gets built in when we trigger a build at the solution level.
Is such a facility available in the Visual Studio 6.0?
In my experience:
when a configuration is chosen (form the list available) in VS6 for a VC++ project, the dependencies (which themselves have multiple configurations defined) get built in some random order. There is no way to control the configurations of dependencies at build time.
"Batch Build" does come close to this but is not as flexible for my purpose.
I have tried various options in the VS6.
Hope I am clear.
Here is a link on the MSDEV command line.
https://msdn.microsoft.com/en-us/library/aa699274(v=vs.60).aspx
There is a way to control the building of dependencies. Specify /NORECURSE and dependencies will not be built.
I use /REBUILD with /NORECURSE to keep the dependencies from getting built.
And I build each project one at a time inside the workspace in a bat file by doing a chdir to the subdirectory and calling MSDEV just for that subproject:
msdev myproject.dsp /MAKE "myproject - Win32 Debug" /REBUILD /NORECURSE > Build.log
Then I cd to the next project directory one at a time.
On a side note, I had difficulties for several years where NMAKE would not work for my specific tasks. Turns out that the PATH environment variable inside MSDEV (Visual Studio 6.0) is different from the PATH environment variable of a command shell you would run NMAKE on.
The Path used by the MSDEV shell is the %PATH% at the time Visual Studio 6 was installed. We use this and poke the registry as needed for MSDEV to get the correct path setup when switching revisions of our software; however this doesn't help update the %PATH%. The MSDEV path can be queried with a query script. I don't have my example handy.
That is why builds in MSDEV sometimes work when builds using the command line don't, as the path to DLLs differ, and any custom build steps that run .exe will not work outside of the MSDEV environment unless the path is updated.
I have a script somewhere that reads the queries the registry to extract the MSDEV path and update PATH of a shell so that batch scripts doing nmake will work as they would inside the MSDEV shell environment. The problem with the REGISTRY QUERY is that the return arguments differ with different flavors of Windows (XP/SERVER2003/...).
One thing I just discovered is that Incredibuild works with the old VS6.0 MSDEV IDE. This is a game changer. It distributes builds. I'm evaluating it now, but it might be useful to anyone waiting for long VS6.0 builds.