DeploymentProvider in manifest of ClickOnce depends on <Import Project=.. in project file - build

When I publish my project in VS2010 for ClickOnce a strange value for <deploymentProvider codebase="file://oldserver/.../....application" /> was present in my manifest file. The name oldserver name was wrong, it had to be replaced.
I didn't have a clue where the name oldserver came from?
In the project file I had
<InstallUrl>\\newserver\...\</InstallUrl>
but when opened, in the project properties in VS2010 oldserver was again displayed as publish folder location.
SOLUTION: In a hidden file called buildconfig.targets this was configured.
This file was referenced in the .proj file:
<Import Project="buildconfig.targets" />
In this file you need
<UpdateUrl>\\newserver\...\</UpdateUrl>
as well!

If you're publishing from Visual Studio, make sure you set the Install Url.
It's in the publish settings (in project settings for the project you are publishing) underneath the install url.
If you're publishing from MSBuild, then you need to set the UpdateUrl property (/p:UpdateUrl=youraddress for example).

When looking at your project in Visual Studio. select Build and then Configuration Manager. Check the information in your build configurations for Debug and Release and make sure they are correct. This is a total guess, but I could see something being set up in there.

Related

Nuget "Manage Packages" dialog. Project names are mixed up

I've got a Visual Studio 2017 solution with several C# class library projects. On disk they take this structure:
MyProduct
MyCompany
MyCompany.ModuleA
MyCompany.ModuleB
MyCompany.ModuleC
But when I look at them in the "Manage NuGet Packages for Solution, the checkboxes show up in the dialog inconsistently. ModuleC appears strangely. Like this:
MyCompany.ModuleA
MyCompany.ModuleB
MyProduct\MyCompany\MyCompany.ModuleC
Also, whenever I build Module C, it keeps creating the following 3 files in its output /obj folder
- MyCompany.ModuleC.csproj.nuget.g.props
- MyCompany.ModuleC.csproj.nuget.g.targets
- project.assets.json
Neither of the other two modules does this.
I'm trying to understand the reason for the inconsistency and to fix it if I can. I have tried combing through the text of the .csproj files for these various projects but I can't spot any differences that might make this happen. And the raw text of the .SLN file project entry all look consistent for each of the 3 modules.
How does NuGet decide what name to put in the Manage Packages for Solution dialog?
Why is NuGet creating those temporary files in the output folder for Module C but not Module's A or B?
How does NuGet decide what name to put in the Manage Packages for Solution dialog?
It is depends on the NuGet manager type, packages.config or PackageReference.
If the project use packages.config, project name will be put in the Manage Packages for Solution dialog. If the project use PackageReference, project file name and relative path will be put in it. That because NuGet will update the project file .csproj when we install the nuget package with PackageReference. So, in the the Manage Packages for Solution dialog, it shows the relative path+project file name, like ClassLibrary1\ClassLibrary1.csproj.
Why is NuGet creating those temporary files in the output folder for
Module C but not Module's A or B?
That because NuGet with PackageReference controls the msbuild items that are generated for these files into the obj\projectname.csproj.nuget.g.props, obj\projectname.csproj.nuget.g.targets and project.assets.json file.
You can unload your project, check if the project file MyCompany.ModuleCuse the PackageReference, like:
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>11.0.2</Version>
</PackageReference>
</ItemGroup>
For some more details, please check this official blog: NuGet is now fully integrated into MSBuild.

MSBuild building project and referenced project with same configuration

I'm using MSBuild to build a project with configuration set to a custom configuration. I have a referenced project (a library) which does not have any cutom configuration set to it. The issue is, it seems like MSBuild is building the project and the project references with the same configuration.
I'm using this command:
msbuild.exe <path>\<project>.csproj /p:DeployOnBuild=true /p:OutDir=<dirpath> /p:Configuration=<CustomConfig>
Im having the follow error:
C:\Program Files
(x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(724,5):
error : The OutputPath property is not set for project
'referencedProject.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this
project. Configuration='CustomConfig' Platform='AnyCPU'. You may be seeing
this message because you are trying to build a project without a
solution file, and have specified a non-default Configuration or
Platform that doesn't exist for this project. [path\ReferencedProjectcsproj]
I cannot find anything related online, if anyone can point me to anything or help me out with this, that would be great.
I found a work around, posting it here in case someone ends up in the same scenario.
The project library did not have the custom configurtation so, i had to edit the csproj file to change the condition of build configuration to this:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' Or '$(Configuration)|$(Platform)' != 'Debug|AnyCPU'">
This will force the compiler to take the leading configurations if it is in release mode or any custom configuration that is mentioned.
I have no found any way that will command MSBuild to choose different configuration project dependencies.

The OutputPath property is not set for project (C++, blank new solution, VS2017)

It happens in a complex solution, but I can reproduce it in a new empty solution.
I built it (ctrl+shift+B) with debug mode, X86, diagnostic.
1> Set Property: _InvalidConfigurationMessageText=The OutputPath
property is not set for project 'ConsoleApplication1.vcxproj'. Please
check to make sure that you have specified a valid combination of
Configuration and Platform for this project. Configuration='Debug'
Platform='Win32'. 1> Set Property:
_InvalidConfigurationMessageText=The OutputPath property is not set for project 'ConsoleApplication1.vcxproj'. Please check to make sure
that you have specified a valid combination of Configuration and
Platform for this project. Configuration='Debug' Platform='Win32'.
This error may also appear in some other project is trying to follow a
project-to-project reference to this project, this project has been
unloaded or is not included in the solution, and the referencing
project does not build using the same or an equivalent Configuration
or Platform.
^ I make sure that there isn't any References that it claims.
Here is what I have tried.
First, a part of my .vcxproj (link to the full file) looks like this:-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
### I will insert something here ###
</PropertyGroup>
According to a SO link and another one, I should insert one of these lines at ### :-
<OutputPath>$(Configuration)\$(Platform)\</OutputPath>
<OutputPath>$(SolutionDir)$(Configuration)\</OutputPath>
<OutputPath>bin\$(Platform)\</OutputPath>
Same as above, but add it in <ItemGroup Label="ProjectConfigurations">
Remove Label="Configuration".
According to another SO link, I also tried AnyCPU or Any CPU (tested in a more complex solution, but a new empty solution doesn't have it.).
A Microsoft link states that Output Path is for C#. In C++, I must use Output Directory. It is OutDir.
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<OutDir>$(Configuration)\$(Platform)\</OutDir>
Do above things, but in a property sheet.
Do above things, but also unloaded-reload project, and even restart VS2017.
After I tried every combination, the warning still exists.
The program can be compiled and run correctly,
but I believe it is a cause of unnecessary recompilation in a much larger solution.
Question: How to solve the warning/error?
OutputPath word in the console is suspicious.
I doubt VS recognize my solution as C#. (is it even possible? - my test project has std::cout)
For some reasons, most SO questions about this error are related to msbuild or C# or .net (another one), not C++.
Reply
There is no such Win32 option in the combo box, so I create a new one.
Configuration Manager > Active solution platform : <New...>
I also make sure that the setting is correct :-
However, I still got the same error message.
You have suspicious platform set - x86, change it to Win32.
UPD.: so the problem appears to be not with the project, but with Visual Studio installation - try to repair/reinstall it.
On my case, we moved the project from a different system, so, some of the directories were pointing to a wrong (non default) path.
On Solution Explorer, right click the project name, select Unload the project, then, right click again and select Edit the xxx.csproj, finally search, check and fix your <OutputPath>bin\Debug\</OutputPath> or <OutputPath>bin\Release\</OutputPath>on your different PropertyGroup conditions.

How to specify which .cpp files to compile based on the current build configuration?

I have multiple build configurations in my project, and I'd like to swap some .CPP files based on the currently selected configuration. How can I do that in Visual Studio 2013?
In the GUI, see properties of a cpp file and set "Excluded From Build" to yes for the configurations where it's excluded.
In the project file would look like:
<ClCompile Include="my_platform_specific_file.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
true
</ExcludedFromBuild>
</ClCompile>
In the IDE.
Select the configuration you want to alter (either from Build > Configuration Manager or the drop down in the toolbar. From the solution explorer, on the file you wish to; right click > Properties > Excluded from Build > Select Yes or No.
In the project file itself, locate the file being excluded
<ClCompile Include="xyz.cpp">
Add the following element;
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MyConfiguration|Win32'">true</ExcludedFromBuild>
Where MyConfiguration is the configuration you wish to exclude the file from.
This might be a good reason to start looking into more generic project managers.
I can recommend you looking into CMake , which is very powerful and can generate VisualStudio projects. The learning curve might be a high (for someone who is used to Visual Studio automation) but the gains are very high.
Some links:
Linking different libraries for Debug and Release builds in Cmake on windows?
http://cmaketools.codeplex.com/ - support for CMake files editing
http://www.youtube.com/watch?v=w9sKd8f0kFo - video displaying cmake integration into VisualStudoi
http://www.cmake.org/Wiki/CMake - random help
The project site is: http://www.cmake.org

How do I convert or create .NET v3.5 solution in C++ VS2012 (specifically the toolset)

I have a library that I need to use in VS2012 C++ solution that requires .NET 3.5. I understand that I can change the framework setting in project file but v90 tool set is not listed even though I have previous VS versions installed. Is there a manual process I can follow to allow this to occur?
Be aware: v90 is VS2008!!! You need v100 (V2010) or v110 (VS2012)!
If you want to change the .NET version, the you need to take a look at the following:
There is no option in the project settings to change this. You must manually edit the project file.
It is still not possible to change the target framework in the VS2010 or VS2012 IDE in the project settings.
The only way to change it, is to manually edit the vcxproj file. For this you need to do the following:
Right-click on the projectin Solution Explorer and select "Unload project"
The again do a right-click on the unloaded project in the Solution Explorer and select "Edit .vcxproj"
In the porject XML file search for the node "<PropertyGroup Label="Globals">"
In this node, find the sub node "<TargetFrameworkVersion>" (if it does not exists, you must add one)
The inner text of this node defines the target framework version. It can be one of the following values: v2.0,v3.0, v3.5 v4.0 or v4.5 (only VS2012)
Save the vcxproj Datei and close it
The again do a right-click on the unloaded project in the Solution Explorer and select "Reload Project"
Example:
<PropertyGroup Label="Globals">
<ProjectGuid>{089A9EBF-5149-462A-BC7E-2B1B59DE123C}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>CPP_VS2010</RootNamespace>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
See also: http://blog.kalmbach-software.de/2014/02/06/change-target-framework-in-ccli-for-vs20102012/