MSBuild ignoring publish profile configuration - visual-studio

I'm trying to publish a bunch of web services and a web site via command line using MSBuild. When I publish, the web services publish successfully but my web site does n't upon checking the logs, I've realized that msbuild is ignoring the build configurations in the specified publish profile and is using the default configurations i.e. Debug|AnyCpu. I've roamed around SO and the internet and found some articles but none worked for me.
Other SO article
I would like to be able to make MSBuild understand that I am trying to publish via the publishprofile. I tested the publish profile and visual studio and was able to execute a publish.
Here is my msbuild command
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe "PATH_TO_PROJECT\PROJECT.csproj" /nodeReuse:false /nologo /p:PublishProfile="FolderProfile" /p:DeployOnBuild=True
Logs
The target "_ConvertPdbFiles" listed in a BeforeTargets attribute at
"C:\Program Files
(x86)\MSBuild\4.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets
(34,37)" does not exist in the project, and will be ignored. The
target "_CollectPdbFiles" listed in an AfterTargets attribute at
"C:\Program Files
(x86)\MSBuild\4.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets
(34,70)" does not exist in the project, and will be ignored. The
target "_CollectMdbFiles" listed in a BeforeTargets attribute at
"C:\Program Files
(x86)\MSBuild\4.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets
(41,38)" does not exist in the project, and will be ignored. The
target "_CopyMdbFiles" listed in an AfterTargets attribute at
"C:\Program Files
(x86)\MSBuild\4.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets
(41,71)" does not exist in the project, and will be ignored. Project
"C:\Git\DXT\DXT.UI.WEB.APP.DEVICES\Dxt.Web\Dxt.Web.csproj" on node 1
(default targets).
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(609,5):
error : The OutputPath property is not set for project
'Dxt.Web.csproj'. Please check to make sure that you have specified a
valid combination of Configuration and Platform for this project.
Configuration='Debug' 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.
[C:\Git\DXT\DXT.UI.WEB.APP.DEVICES\Dxt.Web\Dxt.Web.csproj] Done
Building Project
"C:\Git\DXT\DXT.UI.WEB.APP.DEVICES\Dxt.Web\Dxt.Web.csproj" (default
targets) -- FAILED.
Build FAILED.
"C:\Git\DXT\DXT.UI.WEB.APP.DEVICES\Dxt.Web\Dxt.Web.csproj" (default
target) (1) -> (_CheckForInvalidConfigurationAndPlatform target) ->
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(609,5):
error : The OutputPath property is not set for project
'Dxt.Web.csproj'. Please check to make sure that you have specified a
valid combination of Configuration and Platform for this project.
Configuration='Debug' 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.
[C:\Git\DXT\DXT.UI.WEB.APP.DEVICES\Dxt.Web\Dxt.Web.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.09
I tried supplying a specific configuration to avoid the Debug|AnyCpu combo but encountered errors since the website has a custom Configuration called Release.Custom and depends on projects that do not have that configuration.
Any help is much appreciated.

If anyone encounters this, I was able to fix my error by changing the value of the Configuration tag to my custom BuildConfiguration i.e. "Release.Custom". It's very stupid considering I've spent a day on this.

Related

VS2017 MSB4057 The target "CreateManifestResourceNames" does not exist in the project

When VS2017 was used to create a stateful solution, producing the standard boilerplate code, the resulting two projects have two different MSBuild versions.
The application uses MSBuild version 1.5.0.
The service uses MSBuild version 1.6.0 (the current "latest").
If I run the solution this way, it runs fine on my local Service Fabric cluster.
But when after I use NuGet to update the application's MSBuild to 1.6.0 (so both application and server projects use the same), the following errors occur.
Severity Code Description Project File Line Suppression State
Error The OutputPath property is not set for project 'gt_strd5.sfproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' P follow a project-to-project reference to this project, this project has belatform='x64'. This error may also appear if some other project is trying toen unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform. gt_strd5 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 737
Severity Code Description Project File Line Suppression State
Error MSB4057 The target "CreateManifestResourceNames" does not exist in the project. gt_strd5 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 2630
I found that after the change, some references in the application's project file continued to reference MSBuild 1.5.0. In my case, the gt_strd5.sfproj file contained four references which needed to be updated from 1.5.0 to 1.6.0. See the snippets from the XML below.
Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')"
.....
Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.**MSBuild.1.5.0**\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')"
To verify this, I went back a couple times and was able to reproduce both the issue and this solution.
Hope it saves someone else some time.
Best Regards
I was getting this error into PCF control.
Run Developer Command Prompt VS2017/ VS2019
a) Remove white space from your folder like Test%20-%20PCFs (source control generated name) should be TestPCFs
b) Go to pcf project folder from cmd line & run msbuild /t:restore
b) Go to cds project folder from cmd line & run msbuild /t:restore
c) On cds project folder, run msbuild
d) For release deployment run msbuild /p:configuration=Release
For other types of projects
a) Remove white space from your folder name
b) run msbuild /t:restore
c) run msbuild

Is there any way to set the ANDROID_NDK_HOME environment variable from within Visual Studio in the project/solution properties?

I'm setting up build and release process for a project that does some Windows and Android development through Visual Studio 2013 (though some projects still have to have 2012 configs). I'd like for the developers to be able to stay within Visual Studio and not have to jump out to System Properties to change their environment variables in order to test another version of the NDK/SDK.
In the property sheets there's a setting that allows you to define a User Macro and expose it as an environment variable. I've followed the instructions from here (Visual Studio Property Pages Environment Variables) however it doesn't appear to be working (at least not for doing Android stuff).
We tried setting the User Macro in the property sheet for the project as well as "Microsoft.cpp.Android.User" but still get the same error when building:
1>------ Build started: Project: libstuff, Configuration: Release Android ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\Android\Microsoft.Cpp.Android.Targets(570,5): error : Could not find the Android NDK, check that your ANDROID_NDK_ROOT path is correct!
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\Android\Microsoft.Cpp.Android.Targets(570,5): error : It's currently: '<unset>'
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\Android\Microsoft.Cpp.Android.Targets(570,5): error : The NDK can be downloaded at this URL:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\Android\Microsoft.Cpp.Android.Targets(570,5): error : http://developer.android.com/sdk/ndk/index.html
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
We also tried a pre build event where we set the environment variable from the command line via a "set" with no luck.
Any thoughts on why this might not be working? Is the build order different when doing Android stuff that would cause the environment variables to be set and exposed after the Microsoft.Cpp.Android.Targets is called?
UPDATE *
A small update on this.
We've been able to narrow this down to an issue with MSBuild and how it loads properties.
If you don't want to set the ANDROID_NDK_ROOT and ANDROID_SDK_ROOT you can create a user macro to set those values.
Those are:
$(AndroidNdkDir) and $(AndroidsdkDir)
When MSBuild tries to execute any android build targets it loads two files.
The first is: C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\Android\vs-android.EnvVars.props
That is where AndroidNdkDir, AndroidSdkDir, and other android properties are set.
The second file depends on the android platform you're on. For example this is the file it's loading for us: C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\Android\PlatformToolsets\arm-linux-androideabi-4.8
In that file all the Gcc properties are set.
For some reason the AndroidNdkDir property that was set in the first file is not set. I don't see any settings in the Import tag in MSBuild that controls how/if other properties are inherited. Could this be some order of operation thing?
After doing some more research is seems like the answer to this is that it cannot currently be done. I found this bullet point on the VS-Android plugin TODO list (https://code.google.com/p/vs-android/wiki/TODO_List)
Ability to override environment variables for SDK/NDK/Ant/JDK on a
per-project basis in property sheets.

Set TargetProfile for an Azure project

I'm getting the following error from a build I'm running through TeamCity on my development machine:
[ResolveServiceConfiguration] WATMessage
[16:02:05][WATMessage] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Windows Azure Tools\1.7\Microsoft.WindowsAzure.targets(354, 5): No default service configuration "ServiceConfiguration.cscfg" could be found in the project.
[16:02:05][Xxx.Azure.Production\Xxx.Azure.Production.ccproj] Project Xxx.Azure.Production\Xxx.Azure.Production.ccproj failed.
The same solution builds okay in VS.NET.
I think what I need to do is set the TargetProfile for each of the Azure projects (there's more than one complaining) to override the default of Cloud but I can't find out where to do this.
So how do I set the Target Profile for an Azure project?
Have you tried setting the target profile at command line?
/p:TargetProfile=MyProfile
Given an Azure service configuration file named "ServiceConfiguration.Production.cscfg":
In your TeamCity project build configuration, go to Build Parameters (step 7)
Add a system property with the name "system.TargetProfile" and a value of "Production"
This pattern applies for any named configuration in the format ServiceConfiguration.[your profile].cscfg.
To work around this problem I have created ServiceConfiguration.Cloud.cscfg for each Azure project using the .cscfg that was being set in the definition.
In my case, I renamed the ServiceConfiguration.Cloud.csfg file, and since the build agent will first look for that file because the default TargetProfile is "Cloud", I had to re-create the ServiceConfiguration.Cloud.csfg file in the same location, then went into the .ccproj file and added this line under the <ItemGroup> node:
<ServiceConfiguration Include="ServiceConfiguration.Cloud.csfg" />
Then I rebuilt and the problem was solved.

TFS2010: Build Configuration Issues

I have customized the build configurations in my solution by deleting the Debug and Release configurations and creating "Dev" and "Test". Everything builds fine locally but I get the following error (and others like it) when building one of the new configurations in TFS.
C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets
(177): Unable to copy file
"bin\CommonServiceFactory.dll" to
"C:\MyApp\Binaries_PublishedWebsites\Epsi.Web\bin\CommonServiceFactory.dll".
Could not find a part of the path
'bin\CommonServiceFactory.dll'.
I'm getting this error for both external and project dependencies. From the posts I've read it seems to be related to the build configuration changes I've made. If I set the TFS build to use the "Debug" configuration I do get a warning but it builds successfully.
C:\MyApp\Sources\MyApp.sln.metaproj:
The specified solution configuration
"Debug|Any CPU" is invalid. Please
specify a valid solution configuration
using the Configuration and Platform
properties (e.g. MSBuild.exe
Solution.sln /p:Configuration=Debug
/p:Platform="Any CPU") or leave those
properties blank to use the default
solution configuration.
Any help would be most appreciated.
MSBuild Command:
MSBuild.exe /nologo /noconsolelogger "C:\Builds\2\MyApp\ci.MyApp.acme.com\Sources\MyApp.sln" /m:1 /fl /flp:"logfile=C:\Builds\2\MyApp\ci.MyApp.acme.com\Sources\MyApp.log;encoding=Unicode;verbosity=diagnostic" /p:SkipInvalidConfigurations=true /p:OutDir="C:\Builds\2\MyApp\ci.MyApp.acme.com\Binaries\" /p:Configuration="Dev" /p:Platform="Any CPU" /p:VCBuildOverride="C:\Builds\2\MyApp\ci.MyApp.acme.com\Sources\MyApp.sln.Any CPU.Dev.vsprops" /dl:WorkflowCentralLogger,"C:\Program Files\Microsoft Team Foundation Server 2010\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Diagnostic;BuildUri=vstfs:///Build/Build/2603;InformationNodeId=449514;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;TFSUrl=http://tfsServer01:8080/tfs/Core%20Development;"*WorkflowForwardingLogger,"C:\Program Files\Microsoft Team Foundation Server 2010\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Diagnostic;
The error message indicates that you do not have the dll in the bin\ directory. If you can get on the build machine, can you check to see where the assemblies of your projects were built to? Make sure the path to the assemblies is the one used by the copying/publishing task to copy the assemblies to the Binaries_PublishedWebistes folder.
If this doesn't help, can you post the msbuild command-line from the TFS build details log up?

TFS build - deployment/package target does not run

We have a TFS build definition set up where we pass the following extra MSBuild arguments in:
/p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;_PackageTempDir="\\server\build";AutoParameterizationWebConfigConnectionStrings=false
This has been detailed elsewhere as a way to have the published files copied to a specific location instead of generating a deploy package.
This unfortunately does not work on our build server, however if I run the exact same msbuild command line as called by TFS on my dev machine then it works perfectly and copies the output files to the location.
I have checked the log file and there is no errors, it just seems to completely skip the publish/deploy step.
Done building target "_BuiltWebOutputGroupOutput" in project "xyz.csproj".
Target "PrepareForRun" in file "c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets" from project "C:\Builds\2\xyz\xyz build\Sources\xyz.Web\xyz.Web.csproj" (target "CoreBuild" depends on it):
whereas on my local machine, after _BuiltWebOutputGroupOutput target is run the package target runs and deploys the files correctly.
I have tried using different paths and even setting the properties in the project file but it seems to make no difference. My local solution and project files are the same as in the repository that the TFS build is using. Is there something config related on our build server or with the build agent that would cause the packaging target not to run?
I was having a similar problem today and found a fix so it maybe worth a look for you. Here

Resources