I am developing a Windows Studio CLI Project to deploy on other machines and was wondering two things if this is the right project type to deploy a solution that uses the Windows.Management.Deployment library because the namespace is not being recognized by the solution file. I have already done some research on Stack Overflow and implemented the following in my .csproj
file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Runtime.WindowsRuntime">
<HintPath>..\..\..\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
Thus far what I have tried have seemed to not be working and I am doubting if my setup is complete. If there are suggestions on how I could get this library to work this is the beginning declarations in my C# file.
using System;
using Windows.Management.Deployment;
using System.Linq;
The line that is causing issues is this line:
var packageManager = new PackageManager();
I am also linking a question which I found useful but did not work in my setup in case somebody comes across this question. How to access Windows.Management.Deployment namespace in a Desktop project in VS2017?
I am using the Nuget Package Manager when I tried to use WindowsRuntime 4.7.0 it said it was unavailable to user.
Edit to `.csproj`
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.InteropServices.WindowsRuntime" Version="4.3.0" />
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Runtime.WindowsRuntime">
<HintPath>..\..\..\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
</ItemGroup>
</Project>