MSBUILD command to generate APPXUPLOAD file for cordova application from Visual Studio - visual-studio-cordova

Can you please guide me with the MSBUILD command line to build appxupload files for a cordova application built using Visual Studio 2015.
Am using the below command but its not generating the appxupload file.
msbuild windowsbuild.jsproj /t:Build /p:Configuration=Release;Platform="Windows-x64" /p:AppxPackageIsForStore=true /p:BuildAppxUploadPackageForUap=true /p:UapAppxPackageBuildMode=StoreUpload
Also in case , I give multiple platforms, like Platform =windows-x86|Windows-x64|Windows-ARM, it gives me an invalid platform name error.
NOTE: Am able to successfully generate the app package using Project - > Create App Package option . I need to automate this outside of visual studio hence exploring the command line option.
Thanks for your help.
RAMYA M

I got the MSBUILD command that worked and generated the AppPackage.,
In the below command , if we change the CordovaBundlePlatforms=x86 OR CordovaBundlePlatforms=x64 , we can get platform specific AppPackage.
I required a single appxupload file for x86,x64 and ARM architecture
The output consists of ps1 file (to install on desktop) , appxbundle and .cer files and also a .appxupload file and I confirm that all of them are working fine.
"C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe" C:\Project\MyCode\platforms\windows\CordovaApp.Windows10.jsproj /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=release /p:Platform=arm /p:CordovaBundlePlatforms="x86|x64|arm"
Thanks for your inputs, appreciate the same.
Regards
RAMYA M

Am able to successfully generate the app package using Project - > Create App Package option . I need to automate this outside of visual studio hence exploring the command line option.
To manually create appxupload file, you need to create .appx and .appxsym files first.
You can Create .appx file with MakeAppx.exe Tool.
.appxsym file is a compressed .pdb file.
Then you can create .appxupload file by following steps:
Place the .appx and the .appxsym in a folder
Zip the folder
Change the zipped folder extension name from .zip to .appxupload

Related

dotnet build ZIP package - remove lengthy folder structure

I'm trying to create a ZIP package of my Azure Function so I can upload each build to a storage account and reference them directly via an app setting instead of performing actual deployments.
In Azure DevOps pipelines, I'm using dotnet build (and tried locally as well) with the following args:
dotnet build Solution.sln /nologo /p:PublishProfile=Release /p:configuration="Release" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)" /p:SkipInvalidConfigurations=true
It works pretty fine and creates ZIP packages of each project that I need to deploy. However, looking inside each ZIP file, it essentially has some parameter and info XML files and a long folder structure where the actual function resides:
FunctionName.zip\Content\C_C\Projects\ProjectName\Main\FunctionName\obj\Release\netcoreapp3.1\PubTmp\Out
I understand that the command is creating a deployment package, hence a bunch of XML files which could be useful for parameter substitutions or transformations.
But I just actually want a ZIP file of everything that resides within that Out folder. Is there any parameter I am missing?
I've checked dotnet publish and haven't been able to create a proper ZIP package on it, seems like you need to zip it up manually.

AssemblyInfo ingrored when building from GitLab-Runner

On a Windows machine there is a GitLab-Runner run from a domain user with admin rights. When I log as this user and call dotnet build -c release to build an ASP.NET Core app, the dll has all the information from the AssemblyInfo.cs file. When I do the same as part of a CI job, the produced dll is missing all this information (for example the version number).
The AssemblyInfo.cs file is not part of the repository, instead, it is produced by a prebuild event (using gitWCRev.exe tool). However after running some tests I can see that the AssemblyInfo.cs is actually generated when the job is run by the runner.
Any help as to why the file is ignored and how to overcome this issue would be appreciated.
At first I thought that this might be related to Pre-build task of Visual Studio project fails in GitLab Runner issue, but I don't get any build errors.
On the same machine, I build a .Net Framework app which has the same AssemblyInfo setup, but is compiled using msbuild /property:Configuration=Release by the runner and the produced dll file has all the expected information.
It turns out the problem was partially related to the AssemblyInfo.cs file not being part of the repository.
SDK-style csproj normally don't list the files in the project, but figure them out based on the folder contents. When dotnet build was run, AssemblyInfo.cs wasn't present in the project directory (GitLab-Runner usually clears out files not present in the repository before starting a job/pipeline), so build tools had no idea they needed to load it. It made no difference that the file was being created by the build tools.
The solution proved to be creating an empty AssemblyInfo.cs file before running dotnet build. This way build tools knew they needed to compile it. Actual compilation still happened after prebuild events, so all the needed information was there.
I created the empty AssemblyInfo.cs file using PowerShell:
New-Item -Path "Properties/AssemblyInfo.cs" -ItemType File
Also, checking the build logs helped me finally figure it out. To get the build logs I've called build tools like this:
dotnet build -c release /flp:v=diag
The .Net Framework app didn't have this problem because it wasn't an SDK-style project. All the files needed for compilation were listed in the project file and build tools knew to load them, even if they were created during the prebuild event.

Nothing to do. None of the projects specified contain packages to restore

I have a web app in dot net along with other projects. when i open the .sln file and publish the web project, it does. But, when I try to publish the web proj using command line and .csproj, it gives an error. "Nothing to do. None of the projects specified contain packages to restore."
I got this after converting my csproj to vs2019 format and running dotnet test. The solution was to ensure i had the right test adapter and framework. My csproj files had both the old Microsoft.VisualStudio.QualityTools.UnitTestFramework reference and the new MSTest.TestAdapter + MSTest.TestFramework + Microsoft.NET.Test.Sdk.
I kept the new ones and my tests were run.
I had this problem in a batch file I use to build a UWP component for release. The build command is
%MSBUILD% CartoType\src\main\single_library\uwp\CartoType\CartoType.sln -p:Configuration=Release;Platform=x64
where %MSBUILD% is the full path to msbuild. I first added an msbuild command with the -t:restore option and got the message reported by the original poster ('Nothing to do. None of the projects specified contain packages to restore').
The solution was to add this command before the command given above:
%MSBUILD% CartoType\src\main\single_library\uwp\CartoType\CartoType.sln -p:RestorePackagesConfig=true -t:restore

MSBuild not compiling with both /p:Configuration=Release and -p:Configuration=Debug

We are attempting to install a clean build of the newest version of Kentico (12) on Azure, using Kudu, in DEBUG configuration. We traditionally accomplish this by setting SCM_BUILD_ARGS to -p:Configuration=Debug, and all is well. But for some reason in this newer version, the project fails to compile, and I see that this is the command being run:
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "C:\Users\User\Documents\GitHub\Project\CMS\CMSApp.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="C:\local\Temp\8d6d315018f5ff9";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="C:\Users\User\Documents\GitHub\Project\.\\" -p:Configuration=Debug
Notice both Configuration=Release and Configuration=Debug. The compilation errors are things like Invalid expression term 'string' on the following line of code:
bool licenseOK = LicenseHelper.CheckLicenseLimitations(FeatureEnum.Ecommerce, out int skuCount, out int maxSKUCount);
This doesn't highlight at all in Visual Studio in Debug or Release mode. I am also able to reproduce locally (as shown in my paths above), and if I change the two configurations to both be the same (regardless of whether I choose Debug or Release), it compiles just fine.
What I know I can do is create my own custom deployment command script file as a work-around, but I guess I don't understand why the above MSBUILD command isn't working in the first place.
Any ideas as to why this would work great for all of my ASP.NET projects prior to this one? One thing I know is that Kentico recently included the Roslyn compiler, which I am unfortunately not that familiar with - could that be part of the issue?
UPDATE #1: It appears all of the compilation errors have to do with code that is only valid in C# 7.0. That could be a clue.
It all came down to the fact that the newer versions of Kentico had code that was only valid in C# 7, and required MSBuild 15 to compile. Here's how I was able to set up Kudu:
Add a file named .deployment in the root of my repo, containing only the contents below. This tells Kudu to use a custom deployment script.
Download the deploy.cmd file from my Azure App Service via FTP to the root of my repo, and update it per https://github.com/projectkudu/kudu/issues/2350#issuecomment-373817740 to use the MSBuild 15 path. Details below.
.deployment file contents
[config]
command = deploy.cmd
deploy.cmd updates
1 - Add -MSBuildPath "%MSBUILD_15_DIR%" to nuget call. Example:
nuget.exe restore "{your .sln file path}" -MSBuildPath "%MSBUILD_15_DIR%"
2 - Replace %MSBUILD_PATH% with %MSBUILD_15_DIR%\MSBuild.exe in both occurrences under step 2. Build to the temporary path
This was all that was needed in order to get the build to complete.
As Keith mentions, it was a compatibility issue with C# 7.0 that Kentico 12 uses. This SO thread mentions that you need to run MSBuild version 15 for C# 7.0 code. I ran a similar debug command for my local Kentico 12 project using MSBuild 15, and it succeeded.

Unable to publish ASP.NET web site using command line

I have a VS 2012 solution(ASP.NET) that contains three projects. I'm trying to deploy/publish the site via MsBuild command line without installing Visual Studio on our build machine.
I am using:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild Myproject.csproj /p:DeployOnBuild=true /p:PublishProfile= pubfile.pubxml /p:Password=user1 /p:AllowUntrustedCertificate=true
MY Command line output show only "build successfully" of the solution but nothing about the publish profile.
The same solution and batch file run successfully on my local machine.
Please suggest If any option for publishing without install VS on build Machine
I had to add the following to my command line
/p:VisualStudioVersion=11.0
or you might have to install Web Deploy on your build machine.
The other thing I had to do was publish from VS and save a publish profile and then used that on the command line. I see you have pubfile.xml, but all I had to do was reference the profile name, not the file name. QA being my profile name from the project. Try removing the .xml on the end of yours.
/p:PublishProfile=QA
Add C:\Windows\Microsoft.NET\Framework\v4.0.30319\ to your %PATH% system environment variable and invoke your command:
msbuild Myproject.csproj /p:DeployOnBuild=true /p:PublishProfile= pubfile.pubxml /p:Password=user1 /p:AllowUntrustedCertificate=true

Resources