I am have Solution with multiple projects. When I run MSbuild with the following Arguments
/p:VisualStudioVersion=12.0 /target:Publish /p:Configuration=Release
it compiles and puts the compiled code in _PublishedWebsites folder. what arguments needs to be added so that packages are created for each project.
thanks
You need to use "Package" target. It creates in zip packages or archivedirs if $(PackageAsSingleFile)==False. "Package" target works only for Web apps
Related
I have a C# solution with VS 2017, containing an app project and a test project. I can use the "create app package" wizard to create one single bundle for x86 and x64. However, I would like to automate this process, which means I need to use msbuild in command line to do the same work.
With the reference from here and here, I got:
msbuild .\MyProject.sln /p:AppxBundle=Always /p:AppxBundlePlatforms="x86|x64" /p:Configuration=Debug
But I will get errors for my test projects, like:
MakeAppx : error : Error info: error 80080204: The package with file name "Tests.XXXX.Shared.Uwp_1.0.0.0_x86_Debug.appx" and package full name "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx_1.0.0.0_x86__xxxxxxxxxxx" is not valid in the bundle because it has a different package family name than other packages in the bundle. The expected package name is xxxx-Test.xxxxTestApp....
My guess is that I should not use "Always" for AppxBundle, but I cannot find any document online mentioning how to set this value as "If Needed". I also tried to add "Never" in project properties for the test project, but the command line argument seems to overwrite that.
So my question is: How to exclude a test project from the solution when creating a bundle using msbuild in the command line?
How to exclude a test project from the solution when creating a bundle using msbuild in the command line?
To resolve this issue, you can build the project file directly when you create a bundle using MSBuild in the command line:
msbuild .\YourProjectFile.csproj /p:AppxBundle=Always /p:AppxBundlePlatforms="x86|x64" /p:Configuration=Debug
Alternatively, you can open test project file and add the following properties at the end of the first <PropertyGroup> element to exclude the test project to be included:
<PropertyGroup>
<AppxBundle>Never</AppxBundle>
</PropertyGroup>
Check this thread and the document for some more details.
Hope this helps.
Our continuous delivery set-up, until recently, was delivering Service Fabric packages using the following command:
msbuild SFApp.sfproj /t:Package
This was necessary because the target Package is unavailable at the solution level. I.e. The command
msbuild SFSolution.sln /t:Package
Fails, as the target does not exist.
As our dependency mesh grows, it gets to a point in which most interfaces projects will not build without a solution file (to work around the "OutputPath does not exist" red herring). There seems to be a way to do that according to this answer. Unfortunately, while targets like Clean work…
msbuild SFSolution.sln /t:SFApplication:Clean
(…snip…)
Build succeeded.
0 Warning(s)
0 Error(s)
…the target Package won't!
msbuild SFSolution.sln /t:SFApplication:Package
(…snip…)
Build FAILED.
"SFSolution.sln" (SFApplication:Package target) (1) -> SFSolution.sln.metaproj :
error MSB4057: The target "SFApplication:Package" does not exist in the
project. [SFSolution.sln]
0 Warning(s)
1 Error(s)
(Solution/project folders/names omitted/paraphrased for clarity. I can provide the actual logs if necessary.)
So the question is: how could I, using the Command Line, build one project using the Package target and the solution file?
Or how can I otherwise package a Service Fabric application from the command line?
It's bad idea to compile sfproj file(and any other project file) without sln, because it can bring wrong content to its output from referenced projects. Only solution has a knowledge about what project to compile in what configuration.
To make Package similar to "Right Click->Package" in VS:
Just add to your sfproj the following target
<Target Name="ForcePackageTarget" AfterTargets="Build" Condition="'$(ForcePackageTarget)' =='true'">
<CallTarget Targets="Package"/>
</Target>
And then running normal build on solution you may trigger the package step by /p:ForcePackageTarget=true :
msbuild yoursolution.sln /t:Build /p:ForcePackageTarget=true /p:Configuration=Release /p:Platform=x64
Actually it performs two-in-one steps, build and package, with respect to Solution Configurations on all referenced projects
MSBuild only supports a small set of target names that can be specified at the solution level. As you've discovered, Package is not one of them. You'll need to execute two separate calls to MSBuild: one which builds the solution and one which calls the Package target on the sfproj. The Package target of an sfproj has a dependency on the Build target so it will ensure that the sfproj and its project dependencies are built.
I had the same problem and fixed it by changing the Platform in the failing projects to explicitly build for x64.
Click Build > Configuration Manager and make sure that the assemblies are compiled for the x64 platform, that should also set the Output Paths in the corresponding .csproj files.
The actual command line action that is being executed is this:
"C:\Program Files (x86)\MSBuild\14.0\bin\amd64\msbuild.exe" "C:\agent\_work\1\s\Project\SFProject.sfproj" /t:Package /p:platform="x64" /p:configuration="release" /p:VisualStudioVersion="14.0"
Use the below script.
C:\Program Files (x86)\Microsoft Visual Studio 14.0> msbuild "Fabric.sfproj" /t:Package /p:Configuration=Release
Service fabric requires Target to be set in x64 platform,
So change all you reference projects target to x64 platform.
you can do this by using configuration properties of your solution. If x64 is not listed in 'Configuration Properties' click configuration manager in the same window and under platform column for the required project add new project platform as x64.
Hope this works for you.
We have had the exact same problem as you had and I have been looking around for a solution all over the web and did some experiments. Those are the steps that worked for us:
Don't manually add a target anywhere as suggested by other answers on StackOverflow. Not necessary. Especially in a CI environment, you want to build the projects separately anyways.
Prepare the projects in the Solution: Change the target platform for all projects to x64
Build the application
msbuild.exe SFAplication.xproj /p:Configuration=Release /target:rebuild
Package the App
msbuild.exe SFAplication.sfproj /p:Configuration=Release /target:Package
Hi I need to publish my code using MSbuild.exe and create a package of the publish code to a location.
Need to understand how target file will work and the arguments I need to pass while calling the MSbuild.exe
If you are looking to keep code in a folder the better way to do it is to package it since your intentions are to deploy it to IIS later. That way the deployment will process will be easier and clean.
Below is the command to create and save package to desired location:
msbuild "Your\Solution\location\YourSolution.sln" /t:build /P:configuration="Debug-Dev" /p:platform="Any CPU" /p:VisualStudioVersion=14.0 /p:DeployOnBuild=True /p:CreatePackageOnPublish=True /p:DeployOnBuild=True /p:DeployTarget=Package /p:PackageLocation="\wherever\you\want"
I'm working on an existing WiX project. The project imports a wix target file.
<Import Project="$(MSBuildExtensionsPath)\MyCompany\MyTargetFile.targets" />
Unfortunately, I cannot seem to find this file anywhere. How was it created in the first place?
As you may know, WiX project files are Visual Studio project files, are MSBuild project files. Target files are MSBuild project files but only contain MSBuild targets that might be used in building projects.
$(MSBuildExtensionsPath) is a common place to put targets files. From the name of your target file and the fact that is it is located under $(MSBuildExtensionsPath), I'd say, you are looking for one that was written by MyCompany and planned to be used by several projects. You might find it on another machine at MyCompany—perhaps on a build server.
Some useful links:
MSBuild
MSBuild Targets
How to: Use the Same Target in Multiple Project Files
I know that msbuild does not support VDPROJ files, but it maybe built using command line devenv.
I want to build all prjects (C#) using msbuild task and only after that starting specific setup project from my solution. Of course this projects has dependencies to previously created C# projects (otput from proj1, proj2, proj3).
How could I do it?
Override AfterCompile (or AfterBuild) task and add Exec command for devenv.exe to compile vdproj files. When you run devenv.exe /build /project you will only build the specified project within the specified solution. Only project files that have changed since the last build will be build. Therefore the dependant projects will not be build unless they have been changed.