How to create an App package for WinUI Projects? - c#

I can create my msbuild app package for WinUI via manual app package creation method.
But, I need to create a App package through command line.
msbuild mysolution.sln /t:Rebuild /p:Configuration=Release;OutDir=D:\#Development\CI\AppPack;Platform="x86|ARM"
When I execute the above command in Powershell, I am facing the below Errors.
So, suggest me any solution for create an app package for WinUI through command line.

Related

Cannot add package to visual studio. (System.Management.Automation)

Trying to add System.Management.Automation package to my project in visual studio because I want to run powershell commands through my code, but am getting the error:
The project does not support adding package references through the add
package command. My dotnet --version is: 7.0.102
I inputted
dotnet add package System.Management.Automation --version 7.3.2
into the package manager console, and was expecting it to work as normal when adding a nuget package, however instead received the error
Error while adding package 'System.Management.Automation' to project
'C:\Users\userone\source\repos\blackjack21\blackjack21.csproj'. The
project does not support adding package references through the add
package command.
No idea what to do.

create NuGet package with custom PMC commands

I was wondering how can I get to develop a toolset that I can then run using package manager console commands to modify my project (analyze or generate code).
Someting like Microsoft.EntityFrameworkCore.Tools that adds add/remove-migration etc. commands.
We can see all commands to interact with NuGet in Package Manger Console from this link. Unfortunately, there is no command to create a nuget package.
( https://learn.microsoft.com/en-us/nuget/reference/powershell-reference )
You can try this command “dotnet pack” in PMC, it effectively created the nuget package in my test.

Is there any way to view Nuget package sources available for visual studio directly from command line

How do I view Nuget package sources in visual studio through command line, WITHOUT going to package manager setting in visual studio? Also, dotnet cli also shows nuget package sources by running "dotnet nuget list source" command. Are these sources outputted by the dotnet cli the same nuget source in VS?
You can download the nuget.exe here: https://www.nuget.org/downloads
Then run this command: nuget.exe sources List
Or you can directly check the NuGet.Config file in %appdata%\NuGet(the full path: C:\Users\ {username} \AppData\Roaming\NuGet)

dotnet restore on .NET Framework project not working

I have a .NET project with the following in its .csproj
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
When I run dotnet restore project-file.csproj I get the following:
Nothing to do. None of the projects specified contain packages to restore.
Why is this? I thought the dotnet cli could work with non Core projects too?
I have nuget packages that are referenced, so I expect the cli to go and download the nuget packages.
dotnet cli works properly with .NET Framework only if the project was created from dotnet new command. If you create project from Visual Studio the structure of .csroj files will be different and you usually cannot run cli commands towards them
Visual Studio only allows you to run nuget commands from nuget console (package manager console) within Visual Studio itself.
If you want to do nuget restore from command line:
Download nuget executable from https://www.nuget.org/downloads
(it is not a installer/package, but actual executable!)
Save it to a folder of your choice and add it to the PATH.
Then, as suggested above: nuget restore solutionname.sln (but this time you don't have to run Visual Studio!)

MSbuild Package via Command line not including all my Assemblies

I am trying to setup a deploy script to do a publish of our website rather than have to open VS to do a deploy/publish.
When i do a publish via VS it will include all referenced assemblies correctly however when I do it via the command line it will not. I am at a lose for what I am missing
My MSBuild command is:
msbuild "myproject.csproj" /T:Package;ResolveReferences /P:Configuration=Debug
/P:DeployOnBuild=True /P:DeployTarget=MSDeployPublish /P:CreatePackageOnPublish=True
/P:MSDeployPublishMethod=RemoteAgent /P:WebProjectOutputDire="PreCompiled"

Categories