Error during Visual Studio Publishing using Webdeploy - visual-studio-2013

I am trying to web deploy from visual studio using the publishing wizard.
I am getting the following error:
Error 101 Specified condition "$(AspNetMerge)" evaluates to "" instead of a boolean.
Am I missing some configuration?

I'm not familiar with AspNetMerge but it looks like its used to combine ASP.NET assemblies. Regardless it looks like the AspNetMerge MSBuild property has not been defined. You can try adding the following to the bottom of your project file (.csproj) file:
<PropertyGroup>
<AspNetMerge>true</AspNetMerge>
</PropertyGroup>
Obviously you should set the value to true or false depending on if you want to merge or not.

Related

how to change CopyRetryCount and CopyRetryDelayMilliseconds values in Visual Stdio

VS 2017 often fails refreshing ASP.NET Core web applications with the following error message:
Beginning retry 1 in 1000ms.
...
Beginning retry 10 in 1000ms.
but when the second try, it runs ok.
Question how to change/customize the configuration values of CopyRetryCount and CopyRetryDelayMilliseconds in a project?
I found a global settings in the file,
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
but what is the appropriate way to define a project level settings about those two?
If you want to override those two properties, you can in your project *.csproj file. It will look like this:
<PropertyGroup>
<CopyRetryCount>2</CopyRetryCount>
<CopyRetryDelayMilliseconds>Put some number here</CopyRetryDelayMilliseconds>
</PropertyGroup>
You just hand edit your csproj file and put those values in there yourself.

Unable to use Visual Studio Code Coverage with Azure Functions

I am using Visual Studio 15.3.5 and Microsoft.NET.Sdk.Functions 1.0.6.
I can run tests fine, but when I analyze the tests with Code Coverage the assembly which contains the Azure Functions is not analyzed. It is not listed in the Code Coverage assembly list. Other assemblies are listed, only the Azure Functions assembly is omitted.
Have anyone got it working?
The reason is that for new project types, the default <DebugType> is portable, which means that the pdb's generated would not have required info needed for CodeCoverage.
Here is how you can change this: in your .csproj, add <DebugType>full</DebugType> to the <PropertyGroup>. e.g. you should have:
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<DebugType>full</DebugType>
</PropertyGroup>
Or you can change this from VS:
go to properties on the project
go to the build tab, then the “Advanced…” button at the bottom
there’s a dropdown for Debugging Information. Setting that to “Full” updates the project with the necessary property

Build .net standard 1.4 class library TFS 2015 on premise

We are building a web API application for a Xamarin forms app. I included a .NET standard class library project to use as my view models. The idea being as we build out the web api endpoints - I will publish the updated class library to our internal NuGet server.
Our CI is failing. When I check in the code - I am getting a build error (using TFS 2015 on premise). The first error I received was
The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.
So I added the XML namespace to the csproj
Now I get this:
There is no target in the project.
Which version of Visual Studio do you use? Can you build the project locally with VS or build with msbuild in command line?
Anyway, based on the error message, it seems related to the version of VS which created the project and the msbuild version (New .csproj project format applied in VS 2017). You can reference below threads to troubleshoot the issue:
For the first error:
The default XML namespace of the project must be the MSBuild XML namespace
Visual Studio .NET 2015 can't open migrated project
For the second error:
Visual Studio 2010 Project Targets
Add the following attribute to the Project element:
DefaultTargets="BuildTarget"
That will tell MSBuild to use the target named "BuildTarget" when we do a build. Next add the following subelement to the Project element (just before the last line, which has "</Project>"):
<Target Name="BuildTarget">
<Message Text="Build selected" Importance="high"/>
</Target>
Then save the file and close the edit window. Then return to the Solution Explorer and right-click on the solution and select "Reload Project". Then build the project. You should get the message "Build selected" along with the output of the build, as in:
So answer is not possible. I have tried install VS 2017 on the agent - that didn't work.
We did find an article that TFS needed to be upgraded beyond Update 3.
I will end up upgrading us to 2017 in a few months - which will make this a moot point.
Thanks for the answers.

Set MSBuild default parameters when building locally

Is there a way to set a default set of parameters for MSBuild to use every time i build locally using Ctrl + Shift + B. I want to append a parameter like /p:MyParameter to the MSBuild call.
Thanks in advance!
I am not sure what parameters you want to pass and how will those be used by your project solution. But if those parameters are ought to be used by your project solution then you can create a PropertyGroup element and use it within your project at the time when VS builds your solution. Refer this tutorial
I assume the scenario is the following: you want to use some MsBuild variable values when debugging on your local machine, but don't want to use them in production.
Add the following directive to the Visual Studio project or .targets file:
<Import Project="User.targets" Condition="Exists('User.targets')"/>
Create the User.targets file - example:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MyProperty>Value</MyProperty>
</PropertyGroup>
</Project>
Exclude this file from Git/Mercurial repository.
Close and restart Visual Studio.
Warning: when you change the referenced file, the changes may not take effect immediately; for them to take effect, either close and restart Visual Studio, or change the time of last change ("touch") on the solution file to force Visual Studio to reload it.

In MSBuild is it possible to determine if I'm running in Visual Studio

Are the any MSBuild properties that Visual Studio sets? I'm looking to have some conditional behavior depending on the version (if any) of visual studio.
The property value you should be using is BuildingInsideVisualStudio, when you are building inside of Visual Studio this property will be set to true. Since ProductVersion is declared in the project file you cannot use it because it will have the same value whether building inside of VS or via msbuild.exe.
<PropertyGroup>
<MyProp Condition=" '$(BuildingInsideVisualStudio)' == 'true' ">Foo</MyProp>
<MyProp Condition=" '$(BuildingInsideVisualStudio)' != 'true' ">Bar</MyProp>
</PropertyGroup>
To directly address the question in your title - if you just want to know if you are being built from VS or not, check the value of IsDesktopBuild which will return true or false appropriately.
Yes, <ProductVersion> is listed in a project file. It matches the Visual Studio version number.
<ProductVersion> will give you the version of MSBuild that is running the build process.
Note that in VS 2010 the build process might be targeting either .Net 4.0 or 3.5 You need to consider carefully if your conditional compilation depends on the msbuild version itself or on the target framework of the build and the tools the build is using. If your condition is based on the target framework, use <TargetFrameworkVersion>.
Of course, if your build also might be run under VS 2008, you need to support proper fallback if <TargetFrameworkVersion> is missing.

Resources