How to rename build output file in Visual Studio 2019 - visual-studio

So I just made some c++ application, using NotificationIcon sample from Microsoft as a reference, and thus I'm stuck with the NotificationIcon.exe output file. The name is really lame and I'd like to change it. I've tried renaming the exe, renaming the solution, the project - whatever else - and my programm just exited with code 0x00 after building. What else should I try?

I tried to do the same thing, but there were a few steps I had to follow in VS2019 just to get set up. If you are not in a similar state, the rest of the answer might not apply.
Downloading the sample: I had to install the Windows 7 SDK, as the download page didn't seem to exist anymore. I'm not sure if you found it elsewhere, in which case you might be starting from different sources.
Converting the .vcproj file to .vcxproj. Visual Studio no longer supports .vcproj, and opening the solution triggered this conversion automatically.
Now, once I have a .vcxproj file, there are two routes to setting the name of the exe:
Right-click the project in VS, click Properties, and find the Target Name field. This defaults to $(ProjectName) so I would have expected that renaming the .vcxproj would have renamed the .exe file.
Edit the .vcxproj file directly, adding <TargetName>Foo</TargetName> into the section that starts with <PropertyGroup Label="Globals">

Related

UNITY_EDITOR undefined in Visual Studio

I'm debugging some code from within the Unity editor that starts with #if UNITY_EDITOR, but UNITY_EDITOR isn't getting defined though I'm running Visual Studio through the Unity editor. I've tried
Ensuring that I've got Visual Studio set in Debug mode (vs. Release)
The Scripting Define Symbols settings, and msc and csc solutions from here: http://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html?_ga=2.148389495.1394951635.1638832224-1796620461.1636419298
I've also tried to just add a #define to the project sheets that Unity is generating, which doesn't work because there's no project files that these files are being opened & debugged through. And, I've regenerated solution files. What am I missing? Thank you!
Edit:
Some additional important information: this behavior isn't happening in all files within the Visual Studio instance, just files that are NOT included inside of any of the the .csproj's in the solution I have open. So, my workspace is .csproj's that do have UNITY_EDITOR defined, but the file I'm opening is from outside of that project. In this case, the .cs file I'm trying to debug into is from a package that is running, so the debugger will drop into it, but no .csproj is generated for this package.
It seems to me that there should be different behavior here, but I'm not sure what it is. Should Unity create a .csproj for packages whose .cs files you can debug into so that you can view them correctly in Visual Studio?
So, finally: in the context of the existing .csproj's that I have open, if I add a line <Compile Include="Full\Path\To\File.cs" />, it works as desired. Kludgy, but it works for my purposes.
In one of the existing .csproj's that I have open, if I add a line , it works as desired. Kludgy, but it works for my purposes.

Visual Studio 2017 How to add missing dll to C++ project?

I have a Visual Studio 2017 C++ project which depends on ffmpeg libraries. As of now it crashes at run time because of the missing dependency avformat-58.dll. I've tried adding this file into the project by dragging it into my project but that does not suffice. I tried looking at the Add Reference screen but it is empty. What can I do?
On the advice of #HansPassant I added the dll(s) to the project as existing external files. I think there should now be an option somewhere to "Copy to output directory" but I'm not seeing it. Here is what I see when I open property pages of one of the dlls.
#sellotape Here is a screenshot of the window when I just single click.
According to this documentation https://learn.microsoft.com/en-us/windows/desktop/Dlls/dynamic-link-library-search-order I can copy the necessary dlls to any directory in the PATH environment variable. There were many dlls already in C:/Windows/System32 already so I just put the ffmpeg dlls there as well and the executable runs.

VS2015 Xamarin.Android: Intellisense can't see Resource.designer.cs

I'm using Visual Studio 2015 with Xamarin.Android. My solution compiles and links fine, with no warnings or errors. It runs correctly on my target device.
However, Intellisense can't find the autogenerated Resource.designer.cs file (which provides all the resource ID constants for things like page design elements from .axml files, string resources, assets and so on).
If I have code like: var button = FindView(Resource.Id.some_button);, then in the edit window the "Resource" part will have a red underline, and if I mouse over it, I see: "The name 'Resource' does not exist in the current context."
In the Output window, if I change the dropdown to show output from Intellisense, I see a line like:
[Failure] Could not find file 'C:\Users\dghenke\Downloads\Widget\Widget\Widget.Android\obj\Debug\designtime\Resource.Designer.cs'.
That path exists up to the Debug\ folder, but there is no designtime\ folder underneath.
Things I have tried:
Closing and re-opening Visual Studio.
"Clean Solution" followed by "Build Solution".
Completely removing my source tree then fetching a fresh copy from source control.
Checking my .csproj file to make sure that <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
is in the first <PropertyGroup> element.
Removing the Resource.designer.cs file from the project and re-adding it.
Things I have not tried (and would prefer to keep it that way): Creating a whole new solution from scratch then manually re-adding all my source files from the original.
Versions:
Visual Studio Professional 2015 14.0.25431.01 Update 3
Xamarin 4.8.0.756
Xamarin.Android 8.1.0.13
What finally worked for me was addding:
<AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>
to the first PropertyGroup in my .csproj file.

Including Text Files in Build of Visual Studio 2013 Solution

I want a text file to be included in the build, so I used Add->Existing Item to load it into the solution. However, I can't open it in a ifstream unless I use an absolute path to the original file. I set Excluded from Build to No and Item Type to Text. For a relative path to file.txt, I tried "file.txt", "../file.txt", "/file.txt" but none of them work. I don't know if it's my syntax that's wrong, or if it's just not included in the build, or both.
The program is in C++.
I came across some old answers that mentioned an option to specify additional directories in the build, but I don't see it in Visual Studio 2013.

using Qt designer in visual studio?

I'm using visual studio 2010, Qt add-in etc all ok, then create new project using Qt add-in... when doubleclicking *.ui (the actual form) file in VS it opens Qtdesigner, then I put some controls on, but that does not change my code at all :/
Qt form is changed it contains those controls but source files are the same as before even after building my project.
I'm I missing something?
I think Qtdesinger shoult put some code for objects which I created using Qtdesigner.
cos without that we must write all the code as if there were no Qtdesigner so Qtdesinger is useles in Visual studio, the same thing we could just do by hand-coding a form interface.
thanks alot.
EDIT:
OK
I've copied this from Qt site:
You are referencing objects from a .ui file...
The Visual Studio code model parser only parses C++ sources, meaning
that widgets or objects defined in .ui files will not be accessible.
To workaround the problem, the Qt Visual Studio Add-in automatically
generates C++ code from the .ui file by saving the file and running
uic on it. This step is done everytime the project is built. If the
code completion does not work, try to rebuild the project. It is
possible that you have to wait some time, before code completion fully
works after updating an .ui file. For more information, you can refer
to the Modifying Project Properties section. It still does not work...
You should refresh the code model, Intellisense. This is done by
opening the solution explorer, invoking the context menu of the
project and activating the item Update Intellisense.
now it looks that I'm having such problems but this does not help at all, update intelisece. I can't see such option in visual studio,
it looks my visual studio add-in isn't working.
it says "You should refresh the code model" Woot? can someone explain me how to do that please.
here are some output warnings when building my project:
Warning 1 warning : No resources in 'C:\Users\Admin\documents\visual
studio
2010\Projects\VisualStudio\test\test.qrc'. C:\Users\Admin\documents\visual
studio 2010\Projects\VisualStudio\test\RCC Warning 2 warning LNK4099:
PDB 'vc100.pdb' was not found with 'qtmaind.lib(qtmain_win.obj)' or at
'C:\Users\Admin\documents\visual studio
2010\Projects\VisualStudio\vc100.pdb'; linking object as if no debug
info C:\Users\Admin\documents\visual studio
2010\Projects\VisualStudio\test\qtmaind.lib(qtmain_win.obj)
I'm going to explain a little bit how things work and the relationships between the files, and hopefully this will solve your problem.
When you edit the ui file using the designer all changes are made to the ui file itself. Then when you build a couple of things will happen.
First... a custom build step will be run on the ui file. This build step runs "uic" as Macke said, and will generate a file called "ui_thenameofyouruifile.h". Where this file is located depends on your project settings, but if you look in your project you should see a folder called Generated Files in your project.
If you look in there you should see the newly generated file. This is the code that is "changed" when you make changes to your form. Now if this file is not updated, or does not exist at all, then somehow your project settings got messed up. In this case I would remove your .ui file from the project and re-add it. The add-in should do it's magic and add all the stuff you need. Build again and it should work. (I assume that is probably your problem)
The second thing that should happen when you build, is that the class that uses your ui file should recompile. Generally when you create a ui file, you also create an accompanying .h and .cpp file. This is where we do any of the fun logic that we might need in our window. The Qt designer will never ever change this class.
In the header file we refer to the ui file by doing this:
namespace Ui {
class thenameofyouruifile;
}
#include "ui_thenameofyouruifile.h"
and then we add a member variable
Ui::thenameofyouruifile UI;
There are a couple of ways to do this, but basically that's the idea. The add-in is supposed to configure your project so that the directory where the generate files go is included in the "additional include directories" in your project settings, but that is another place to check to make sure that your code is really linking with the correct generated file.
If Qt Add-In installed properly, it should generate the custom build step for Qt related files (.ui or moc file). I have not tried Qt Add-in with VS 2010, but with VS 2008 it's okay.
The work-around for your problem, you need to add manually the custom build step for each ui file you have in the project. To do this, the step is:
Right clicked the ui file, and click the properties (I'm using VS-2008 to do this step, and expect this may not be much different in VS 2010).
Under custom build step, add this in the command line: "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_$(InputName).h" "$(InputPath)"
And add this under output: ".\GeneratedFiles\ui_$(InputName).h"
And this under additional dependencies: $(QTDIR)\bin\uic.exe. Then click apply / ok.
If this is done, the ui file is compilable, (when you right click it, it can be compiled), so when the ui file content change, the new ui code (.h) file is regenerated.
Alternatively, to reset the VS project file (vcprojx) you can create Qt project in Qt creator, (or if you have already one), and then convert the Qt creator project (.pro) into vcproj using this command line:
qmake -spec win32-msvc2010 -tp vc
This will create the vcproj with the proper custom build step for you (in case you have many ui files, then you don't need to do the first approach).
If you've created a Qt widget using the new class wizard, stuff should work as expected.
I.e. your .ui files are compiled by Qt's uic to .cpp files, i.e. you need to build your project to get these changes into the ui-class.
So, the .ui files should be added to the project, and have some special build rules that invoke 'uic' on them. If that's not the case, try and re-add them to your project (that way, the Qt add-in should configure the build rules)
Normally, you have a class that inherits QWidget which then includes the compiled cpp-class, by one way or another, usually as a member variable (but inheritance is an option too).
Adding an .ui-file straight up should work too (if you're in a Qt project, which you are..), but obviously something is wrong.
Does the example projects work as expected?

Resources