How to avoid msbuild publishing referenced project? - visual-studio

I have a Visual Studio 2013 solution (called Twins) with 3 projects:
Class Library (Lib)
WCF Service Application (WCF)
ASP .NET MVC Application (Site)
References
Site references WCF and Lib.
WCF references Lib.
I am trying to build and publish (WebPublishMethod = FileSystem) Site and WCF from the command line using msbuild.
This works for WCF project (split over multiple lines for clarity):
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
.\Twins.sln /t:Wcf
/p:"VisualStudioVersion=12.0;PublishProfile=wcfprofile;DeployOnBuild=true"
This fails for Site project:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
.\Twins.sln /t:Site
/p:"VisualStudioVersion=12.0;PublishProfile=siteprofile;DeployOnBuild=true"
Short error message
The value for PublishProfile is set to 'siteprofile',
expected to find the file at
\Twins\Wcf\Properties\PublishProfiles\siteprofile.pubxml'
but it could not be found.
Detailed error message
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4331,5):
error :
The value for PublishProfile is set to 'siteprofile',
expected to find the file at
'C:\Users\USERNAME\code\Twins\Wcf\Properties\PublishProfiles\siteprofile.pubxml'
but it could not be found.
[C:\Users\USERNAME\code\Twins\Wcf\Wcf.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4338,4):
error :
PublishProfile(siteprofile) is set.
But the $(WebPublishMethod) does not have a valid value.
Current Value is "".
[C:\Users\USERNAME\code\Twins\Wcf\Wcf.csproj]
In Visual Studio I can right click on Site, select publish, select the sitepublish profile and only the site is published.
How do I build and publish the Site project from the command line just like I can do from inside Visual Studio? (Whether or not the WCF project is also built/published is not important.)

Related

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.

MS build of solution which references dll from other class library project.

I am using Jenkins for CI.
My application- ( solution name HP_app) is a vb.net windows forms ( repository https://XXXXXX.org/scm/HP/HP_app.git)
Windows forms References .dll from class library (solution name HP_app_lib)(repository https://XXXXXX.org/scm/HP/HP_app_lib.git)
I have set up two separate Jenkins job for each solution.Class library solution builds perfectly.Now windows forms solution is dependent on HP_app_lib.dll.
<SpecificVersion>False</SpecificVersion>
<HintPath>..\HP_app_lib\bin\Debug\HP_app_lib.dll</HintPath>
</Reference>
How can I build windows forms using msbuild.
#user2211290 The windows form project and that assembly files structure should be like this:
HP_app_lib
--bin
--Debug
--\HP_app_lib.dll
[windows form project folder (e.g. HP_app)]
--[windows form project name].vbproj
After that build windows form project directly through msbuild, for example: MSBuild [windows form project name].vbproj.
I found the solution.
As windows forms solution is Referencing class
library-Which alone stand alone VS solution also going continuous changes.
Below project reference in MSBuild file is changed from
<HintPath>..\HP_app_lib\bin\Debug\HP_app_lib.dll</HintPath>
To file path in Jenkins server <HintPath>C:\jenkins\workspace\CI_FASET_LIB\bin\Debug\FASETLib.dll</HintPath>
Few more tips.
Normally Build servers will not come with Visual Studio installed.Jenkins MS build is searching for Microsoft.office.Interop.word.dll and ADODB.dll in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.
So I have moved these dll's from dev machine to Build server .net framework path.
Dev machine as we got VS,these are located in.
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Visual Studio Tools for Office\PIA\Office14

Visual Studio 2010 Web deployment project file error

I am trying to build a web development project in VS2010, but although all the individual projects build the web deployment project returns the following error.
C:\Program Files (x86)\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets(1520,9): error MSB3462: Either MetabasePath or VirtualPath must be specified.
The .Net framework for the main web project is set as .Net 3.5.
Has anyone seen this error before as googling it returns very little.
EDIT: this project was upgraded from VS2008

No compile errors when reference added, but errors seen upon build

A solution was just converted from VS 2008 to VS 2010. My VS 2010 build is failing with the popular "The type or namespace X could not be found". When I go to the project and go to Add References and add the appropriate project dll, the class name appears in blue text as if .NET found the correct class. However, when I go to the Build menu and select "Build Solution" I get the "namespace not found error" and the class name is no longer blue.
Thanks.
Your project is probably using the .NET 4.0 Client Profile, rather than the full .NET 4.0 framework.
Go to Project > Properties > Application and set "Target framework" to .NET Framework 4.
For some reason Microsoft set this as the default framework instead of the full one for projects in VS2010, and compilation fails with this cryptic error message for any referenced types/namespaces in assemblies which were built against the full framework.

MSBuild output vs Visual Studio output against a COM interop

I am attempting to a get a isolated build environment setup in my dev team.
The problem that I am presently hitting is a DotNet project which has a reference to a VB6 COM assembly.
The COM assembly is registered on the build system, but when I run msbuild against the sln I get the following error:
error MSB3303: Could not resolve COM reference "f630637a-718a-41c7-9c52-41f934dc4625" version 3.2. Object reference not set to an instance of an object.
The GUID for this assembly is correct, and if I load the solution up in Visual Studio it builds fine and generates Interop.* assemblies as required.
I do not wish to have the Visual Studio build as a requirement in the build steps.
How can I get msbuild from the command line to build the Interop assemblies the same as VS?
It appears that msbuild does not follow the project dependencies the same way as the IDE - as per this question
If I build the specific project that was failing before building the entire solution everything is good.

Resources