How can I set the output path of a vc++ project different than its dependencies (nuget)? - warnings

Premise
I have a Visual Studio 2015 solution containing different VC++ projects.
Some of them (EXE and some DLLs) have the $OutDir set to default "$(SolutionDir)$(Configuration)\" (i.e. "C:\MySolution\Debug\").
For some other projects (DLLs), I need to change the output path to a sub-directory of the "default" $OutDir (i.e. "C:\MySolution\Debug\Pieces\".
Example directory tree:
C:\MySolution\Debug\
MyProgram.exe
Dependency.dll
.\Pieces\
MyPiece1.dll
MyPiece2.dll
Constraints
the "Pieces" DLLs depends on a third-party Dependency.dll (through NuGet package), which I cannot modify.
Usual solution
The usual way for this is to change the $OutDir project setting for "pieces" projects, but this will also force their dependencies to be output in the same sub-dir.
This is not wanted and also created problems in debugging and packaging of the entire solution.
What I tried so far
I tried to:
1. keep the $OutDir the same for all projects
2. change the "pieces" $TargetName to "Pieces\$(ProjectName)"
This seems to work (both MyPiece*.dlland Dependency.dll are correctly placed and debugging is fine), but unfortunately Visual Studio generates the following warning:
warning MSB8012: TargetName(Pieces\MyPiece1.dll) does not match the Linker's OutputFile property value (MyPiece1). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
This warning is somewhat confusing, because the %Link.OutputFile in the project settings looks correct:
$(OutDir)$(TargetName)$(TargetExt) => C:\MySolution\Debug\Pieces\MyPiece1.dll
Question
What is the correct approach to solve my problem?
How do I force Visual Studio to output some of the generated files in a different path, but still having their Nuget dependencies in the "default" $OutDir?
I've searched the web and StackOverflow already, but I can't find a suitable answer.
Note: my problem is not related to upgrading a pre-VS2010 solution (as in Microsoft official notes on warning MSB8012 after solution upgrade and asked on StackOverflow).

Related

How exactly do solution configurations work in Visual Studio?

When in a .sln file, you have the default choices of 'Debug' and 'Release'. From what I understand these are 'build settings' of some sort differ depending on the kind of build you are doing?
I recently played around with creating my own settings, and found (much to my surprise) that creating the configuration name didn't seem to create the symbol as recognized by:
#if MY_SHINY_NEW_SYMBOL
Console.WriteLine("TESTING MY SYMBOL");
#endif
And on the Microsoft docs I can see that there is code to allow you to actually define the symbol (presumably separately from just creating one in the Configuration Manager):
#define DEBUG
// ...
How do these symbols work and where are they configured?
i'm asking because I accidentally created a symbol called 'local'. I deleted it and then created a symbol called 'Local'. And I'm getting compile errors because it seems that the 'local' symbol still exists and I can't overwrite it with a symbol using a different case.
I haven't configured the symbol at all, I'm using the variable $(ConfigurationName) in my pre-build event commands.
I'm actually fairly sure this is a Visual Studio bug, since I would think that deleting a configuration, recreated the same configuration with different case, would NOT result in the original configuration reappearing.
Build configurations become MSBuild variables that can be referenced in MSBuild properties in the csproj file (remember that .Net project files are actually MSBuild scripts).
In particular, the Visual Studio Project Properties window will let you set most properties on a per-configuration basis (by wrapping it in a conditional block).
In particular, the DEBUG symbol is set like this (you'll see this in every csproj file, but a bit less simple):
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
...
<DefineConstants>DEBUG;TRACE</DefineConstants>
...
</PropertyGroup>
You could also replace this and set a symbol for the configuration directly:
<DefineConstants>$(Configuration)</DefineConstants>
However, VS is likely to change that if it saves your project file.

Monodevelop fails to build, can't find Microsoft.DiaSymReader.Native.x86.dll'

I am trying to build a web api project using monodevelop on a mac. The thing is that after a few hiccups (explained in a question that turned out to be so messy I have just deleted) I get to the point of getting this error
/Users/myuser/git/LiveData/LiveData/CSC: Error CS0041: Unexpected error writing debug information -- 'Windows PDB writer is not available -- could not find Microsoft.DiaSymReader.Native.x86.dll' (CS0041) (LiveData)
In a windows machine the same project builds using visual studio targeting mono 4.5.
When I click on the error it tells me that /Users/myuser/git/LiveData/LiveData/CSC doesn't exist
Another thing is that in the folder structure of the solution there's a package folder (not the one inside the project) and inside this one I have a folder called Microsoft.Net.Compilers 1.3.2 that has inside another folder called "tools" that contains among other things csc.exe and the dll thta can't be found.
I have tried to install the dll directly in the project using nuget but even if it was installed the build showed me the same error
Thanks,
As for workaround for now you can just limit usage of Microsoft.Net.Compilers to Release configuration (edit *.csproj file):
<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="'$(Configuration)' == 'Release' And Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />
take a look at beginning of condition:
'$(Configuration)' == 'Release'
This way I can build and debug locally and build my project ie. in appharbor.
Building the project in release configuration should fix it!
This might not be completely related but may be helpful in some ways. Regarding the issue on 'could not find Microsoft.DiaSymReader.Native.x86.dll', have a look at this issue on GitHub: https://github.com/dotnet/cli/issues/3016
It seems like the solution is either:
Dependency to Microsoft.NETCore.Platforms needed for RID graph which
was missing. Any package which has transitive dependency on it (like
NETStandard.Library) could also make things work.
Adding dependency to "Microsoft.NETCore.Platforms": "1.0.1-" or
"NETStandard.Library":"1.5.0-" make it work.
adding Microsoft.NETCore.Platforms works as well

Renamed SSIS Package and Now Don't Have Access to my Solutions

I made a goof and renamed my SSIS package without fully understanding what I was doing. Now I get "one or more solutions couldn't be added..." I then go to my solution explorer and no solutions are there. Please note that I've been working on this project for 6 months. I checked the project obj folder and all my solutions are there. I'm pretty sure I have to rename something else. Will somebody please help me. I am an intern and am FREAKING OUT.
Let's examine what's happening. I am using SSIS 2012 in this example but the steps will be the same for 2005 to 2014. This assumes you have turned off "hide file extensions".
Visual Studio is an Integrated Development Environment, IDE, for developing software. The outermost concept is a Solution. See 1 below. Solutions solve a problem as a whole. A solution might need multiple tools to solve a problem. A tool in this case, is a Project (#2). Depending on the type of project, different folders and such will appear in section 3. This is an example of an SSIS project.
If you don't see your solution, there's a question for that Solution Folder Not Showing in Visual Studio 2010 - How Can I Make It Visible?
If I Rename the project JeffOrris to JeffOrris2 and close Visual Studio, it will prompt me to save changes to JeffOrris.sln (and optionally, the project). If I click No, when I reopen the solution, I am greeted with the following error message along with Visual Studio indicating that my project JeffOrris is unavailable. :'(
---------------------------
Microsoft Visual Studio
---------------------------
One or more projects in the solution were not loaded correctly.
Please see the Output Window for details.
---------------------------
OK
---------------------------
To start fixing things, you have to get Visual Studio to play ball. You can do this one of two routes. The first is to Add the renamed project back into the solution. Add... Existing Project... and then find your .dtproj file (or .whatever it was with 2005/2008) Assuming that loads fine, you can right click on the one that isn't loading and select Remove. Then click "Save All" or Ctrl-Shift-S
Option 2, which is what I do is to go mucking about with files. Find where your .SLN is. If your project is still open, it will indicate it under properties but once it's bolloxed then you'd need to right click and choose Open Folder in File Explorer.
However you get here, look at what you have.
A solution is represented on disk by a .sln file. That's a text file, might be UTF-8 but it's human readable text. The .suo file is binary that keeps track of what you have open and such. It doesn't matter, the .sln does.
Take a peek inside your solution file. Knowledge is only good for you
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{159641D6-6404-4A2A-AE62-294DE0FE8301}") = "JeffOrris", "JeffOrris\JeffOrris.dtproj", "{631559E9-5ED5-4F63-B74E-BFB6CBAE89C5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Development|Default = Development|Default
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{631559E9-5ED5-4F63-B74E-BFB6CBAE89C5}.Development|Default.ActiveCfg = Development
{631559E9-5ED5-4F63-B74E-BFB6CBAE89C5}.Development|Default.Build.0 = Development
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Of importance is the line starting with Project. That says I, the Solution, have a Project called JeffOrris and the project file can be found, relative to my location, at Folder called JeffOrris and inside there a file named JeffOrris.dtproj
The "trick" then is to make your subject and verbs agree. Or in this case, make your Solution and your .dtproj file agree. That'd be #6 below. After saving the solution file, Visual Studio should prompt you to reload it and whoosh, your project is back.
If you have inadvertently renamed the .dtproj file, then you can rename it back. Again, save all

ReSharper: Namespace does not correspond to file location

I renamed a folder and updated my namespace declarations, but ReSharper 6 claims that the namespace should be a reflection of how it was before the rename. Where is it storing the file location data?
Check to make sure your assembly name matches your new namespace. If you've changed your folder structure to match your new namespace, you may still see the ReSharper alert until you update the project properties.
As delliottg's comment says, in Visual Studio, go to
Project > [project name] Properties > Application
and change "Assembly name" as well as "Default namespace".
I also had this problem with a folder/namespace and none of the above steps fixed it.
In my case I had to do this in Visual Studio:
Right-click the "problem" folder in the solution explorer to open the properties
Ensure the "Namespace Provider" is set to true
This fixed the ReSharper issue for me and I was able to adjust namespaces as normal.
Root namespace is needed to be changed as following.
I use Resharper 2019.3.2 in VS 2019 vs 16.5.2 and I had similar issues.
When developing, I first work out my namespace hierarchy in a single project, then split the project in seperate class libraries. In the first stage, it is convenient to always let the subdirectory correspond to the namespace.
For example, my prototype MeshTools.dll project currently contains:
Meshtools ........................ 3 cs-files in \MeshTools
MeshTools.HeightField .......... 2 cs-files in \MeshTools\HeightField
MeshTools.VectorTools .......... 3 cs-files in \MeshTools\VectorTools
The above answers all assume one single namespace per project. Renaming directories manually may confuse Resharper and that can be repaired by setting the default assembly in the .csproj file to the proper namespace. Thanks for the tip.
However in my case, I have several namespaces in a single project, with each namespace in a Solution directory corresponding to a real directory. Setting the default assembly "Meshtools" does not affect ReSharper behaviour for HeightField and VectorTools, when things have gone wrong with the renaming.
I googled this issue and came by https://www.jetbrains.com/help/resharper/Refactorings__Adjust_Namespaces.html#
It turns out there is a right-click option on a Solution Directory -> Properties. You will find an option to decide, if the Solution Directory is a NameSpace provider or not. When something has gone wrong, Visual studio will reset the field to False. Set it back to True and Resharper will correctly refactor namespace or file location when needed..
If you're using JetBrains Rider, go to the Solution Explorer and right click on the csproj file, then properties in the context menu. In my case the Assembly Name was already updated but "Root Namespace" wasn't, updating Root Namespace allowed JetBrains to automatically update all namespaces.

Using MySQL in VC++

I am trying to connect to MySQL using C++. The IDE that I am using is Visual C++ 2010. I followed the steps on the MySQL dev page (http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html). I followed the steps exactly as given although i used a different OS(Windows). I get many linker errors in the process, which I am finding difficult to debug. Could somebody direct me towards a better or a simpler approach to acces MySQL using C++.
P.S. I have downloaded mysqlconnector for C++.
You could try mysql++, but you'll encounter the same linker errors I bet.
Have you set the include path (C:...\MySQL Server 5.1\include) and the library path (C:...\MySQL Server 5.1\lib\debug) ? In VC2010 to set global settings you have to :
VS2010 introduces the user settings
file
(Microsoft.cpp..users.props)
to control global settings including
Global search path. These files are
located at
$(USERPROFILE)\appdata\local\microsoft\msbuild\v4.0
directory.
The issue you are seeing is a bug in
the UI. To make it possible to change
the ordering of these read-only
directories, here is the workaround
that you can apply:
open up the property manager,
right click on the .user.props file to bring up the property page
open up VC++ Directories -> Include Directories, add new paths after
$(IncludePath)
Click on the "Edit" dropdown on VC++ Directories -> Include
Directories property, the user
directories as well as the inherited
values will show up in the upper pane
you can move the directory orders as you wish and save.
http://connect.microsoft.com/VisualStudio/feedback/details/550946/vs-2010-how-to-change-vc-directories-inherited-values-read-only