I create .net with dotnet cli and visual code. how to tell msbuild to join other dll into application.dll or as static dll? currently when i compile, all package as dynamic. it fills output folder with package dll. i want to select which package join into application.dll.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0-preview.7.22376.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0-preview.7.22376.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Selenium.WebDriver" Version="4.4.0" />
</ItemGroup>
</Project>
Related
I am working on a Click Once Deployment Application. I can produce a working build by using the publish menu inside Visual Studio 2022. When I build the application outside of the Visual Studio using MSBuild it successfully installs but fails to launch. The goal is to in turn build that application with Azure DevOps Pipelines.
This is the what I run with MSBuild
msbuild CompanyPortal.Desktop.csproj -t:publish -p:PublishDir="C:/Users/rebel/Desktop/CompanyPortalBuild" /p:PublishProfile=ClickOnceProfile
Here is my publish profile
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateWebPageOnPublish>False</CreateWebPageOnPublish>
<GenerateManifests>True</GenerateManifests>
<Install>True</Install>
<InstallFrom>Disk</InstallFrom>
<IsRevisionIncremented>True</IsRevisionIncremented>
<IsWebBootstrapper>False</IsWebBootstrapper>
<ManifestCertificateThumbprint>xxxxxxxxxxxxxxxxxxx</ManifestCertificateThumbprint>
<ManifestKeyFile>CompanyPortal.Desktop_TemporaryKey.pfx</ManifestKeyFile>
<MapFileExtensions>True</MapFileExtensions>
<OpenBrowserOnPublish>False</OpenBrowserOnPublish>
<Platform>Any CPU</Platform>
<PublishDir>bin\publish\</PublishDir>
<PublishUrl>bin\publish\</PublishUrl>
<PublishProtocol>ClickOnce</PublishProtocol>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishSingleFile>False</PublishSingleFile>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>True</SelfContained>
<SignatureAlgorithm>sha256RSA</SignatureAlgorithm>
<SignManifests>False</SignManifests>
<TargetFramework>net6.0-windows</TargetFramework>
<UpdateEnabled>False</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateRequired>False</UpdateRequired>
<WebPageFileName>Publish.html</WebPageFileName>
</PropertyGroup>
</Project>
Below is the csproj of the program I am trying to build and deploy using ClickOnce. This is a WPF using WebView to Display a Blazor wasm application
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<IsShippingPackage>false</IsShippingPackage>
<AssemblyVersion>2.9.96</AssemblyVersion>
<FileVersion>2.9.96</FileVersion>
<Version>2.9.96</Version>
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
<PackageIcon>Company_Portal_Icon_512.png</PackageIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Wpf" Version="6.0.101-preview.11.2349" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CompanyPortal.Components\CompanyPortal.Components.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="Company_Portal_Icon_512.png">
<Pack>True</Pack>
</None>
</ItemGroup>
</Project>
Is there something I am missing? That would cause the build to work perfectly when it's built from Visual Studio but not from MSBuild?
I'm running into an issue with an invalid URI when attempting to run the Wix V3.11.2 toolset via Powershell. I'm not sure what is causing the error.
Full error:
$ candle.exe Product.wxs
Windows Installer XML Toolset Compiler version 3.11.2.4516
Copyright (c) .NET Foundation and contributors. All rights reserved.
Product.wxs
candle.exe : error CNDL0001 : Invalid URI: The hostname could not be parsed.
Exception Type: System.UriFormatException
Stack Trace:
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at Microsoft.Tools.WindowsInstallerXml.Preprocessor.Process(String sourceFile, Hashtable variables)
at Microsoft.Tools.WindowsInstallerXml.Tools.Candle.Run(String[] args)
The test file I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="My Software"
Language="1033"
Manufacturer="My Company"
Version="1.0.0.0"
UpgradeCode="GUID-HERE">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature"
Title="The main feature"
Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
</Wix>
I replaced the UpgradeCode with a placeholder for this post; a unique code
is there when I run it. I've tried installing via the download button from the official site, installing via github exe download, and installing via dotnet tool install. All 3 instances give me the same error. I'm hoping I'm missing something simple.
Figured it out. Turns out, that is the error message received if the .NET installation is the wrong version, but WiX ends up being installed anyways. For WiX V3.11, the .NET 3.5 framework is needed.
How can I add a reference to PresentationCore to an existing .NET 5 class library?
Set TargetFramework and UseWPF:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>
I'm using System.IO.Compression.ZipFile NuGet to extract .zip archive. The code looks like this:
ZipFile.ExtractToDirectory(gameFolderAbsolutePath + api, gameFolderAbsolutePath, true);
There is no issue when using application as compiled in any configuration (Debug / Release). The problem occurs when the application is run after it's publish, with these settings:
After this published app is run it crashes at the code line shown above giving this exception message: System.TypeLoadException: 'Could not load type 'System.IO.Compression.ZipFile' from assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.'
I'm not aware of why should have System.IO.Compression.ZipFile look for something in Newtonsoft.Json tho.
Publish.pubx.xml:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>P:\ReleaseCandidate\installer-binaries\data</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>True</PublishReadyToRun>
<PublishTrimmed>True</PublishTrimmed>
</PropertyGroup>
</Project>
PackageReferences from .csproj:
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
<PackageReference Include="NLog" Version="4.7.3" />
<PackageReference Include="RestSharp" Version="106.11.4" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="106.11.4" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
</ItemGroup>
Even tho I have tried many times to publish the application with 'Trim unused assemblies (in preview)' checkbox unchecked, it turned out it haven't been taken into process. The problem had been resolved after removing the redundant tags from the .csproj.
I found a method to manually publish a regular WPF Application, but i need the same instructions for a WPF Browser app instead. Here is the regular WPF App howto: http://msdn.microsoft.com/en-us/library/xc3tc5xx(VS.80).aspx . If anyone knows what changes I need to make to my mage commands to make it work for XBAP please let me know. Thanks.
I had to alter the name of the default "Application Files" folder for one of our customers who doesn't like spaces in file or folder names and this meant re-signing the xbap after the publish. Here's the msbuild script I use to automate the process:
<Target Name="PublishWebsite" DependsOnTargets="CleanWebsiteOutputPath;CleanOutputPath;CleanWebsiteReleasePath">
<!-- Compile Website -->
<MSBuild Projects=".\Some.Namespace.Web.Site\Some.Namespace.UI.Web.Site.csproj" Targets="Clean;Rebuild;" Properties="Configuration=Release" />
<!-- Copy Website files to release folder -->
<ItemGroup>
<SiteFiles Include="Some.Namespace.UI.Web.Site/**/*.*" />
</ItemGroup>
<Copy SourceFiles="#(SiteFiles)" DestinationFolder="..\rel\Website\%(RecursiveDir)" />
<!-- Remove source code and source control files from website -->
<CallTarget Targets="CleanWebsiteAfterPublish" />
<Message Text="Website Published" />
<!-- Rename "Application Files" folder and re-sign the xbap -->
<StringReplace Pattern="\." InputString="$(ApplicationVersion)" Replace="_">
<Output PropertyName="VersionUnderscored" TaskParameter="Result" />
</StringReplace>
<MSBuild Projects=".\Some.Namespace.UI.WPF\Some.Namespace.UI.WPF.csproj" Targets="Publish" Properties="Configuration=Release;" />
<Exec Command="move "..\bin\Release\app.publish\Application Files" "..\bin\Release\app.publish\ApplicationFiles"" />
<Exec Command="$(MageExe) -update ..\bin\Release\app.publish\SomeApp.xbap –AppManifest ..\bin\Release\app.publish\ApplicationFiles\SomeApp_$(VersionUnderscored)\SomeApp.exe.manifest -wpf true -cf ..\ext\Signing\SomeApp.pfx -pwd password" />
<!-- Move published files to Release directory -->
<ItemGroup>
<XbapPublishFiles Include="..\bin\Release\app.publish\**\*.*" />
</ItemGroup>
<Copy SourceFiles="#(XbapPublishFiles)" DestinationFiles="#(XbapPublishFiles->'..\rel\Website\%(RecursiveDir)%(Filename)%(Extension)')" />
<Message Text="XBAP Published" />
</Target>