dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

ClickOnce deployment goes rogue after upgrading to .Net Framework 4.8 #5485

Open cilerler opened 4 years ago

cilerler commented 4 years ago

I upgraded a project from .Net Framework 4.7.1 to .Net Framework 4.8, and ClickOnce stopped working. It deploys, but it is no longer generating all of the files, and it is no longer respecting the path of the content files. I appreciate any idea you may have to fix this issue, thanks in advance.

Here is the side by side comparison image

Sample repository to reproduce

Here is a link for sample repositories.

Initial steps

  1. Open a DeveloperCMD or Developer Powershell
  2. Change the location to the application folder's location. For me, it is cd ~\Source\github\cilerler\issue.microsoft_msbuild_5485

ProjectReference method

  1. Run the command MSBuild app.xml -p:BuildId=1 to generate initial output. It will produce a publish folder at .\artifacts\publish.

PackageReference method

  1. Run the command MSBuild library.xml -p:BuildId=1 to generate version 0.0.0.1 of the NUPKG file. It will place it in the folder at .\artifacts\packages which project is set up to look for as a local NuGet service.

  2. Change the snippet below

    <ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj">
      <Project>{705ccf76-2c45-43d3-a839-7591813b5522}</Project>
      <Name>ClassLibrary1</Name>
    </ProjectReference>

    with the snippet below

    <PackageReference Include="ClassLibrary1">
      <Version>0.0.0.1</Version>
      <PrivateAssets>analyzers;build</PrivateAssets>
    </PackageReference>

    in ConsoleApp1.csproj

ClassLibrary.csproj

...
  <ItemGroup>
    <Content Include="Lookup\TextFile1.txt">
      <PackageCopyToOutput>true</PackageCopyToOutput>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <!-- <Link>Lookup\%(RecursiveDir)%(FileName)%(Extension)</Link> -->
    </Content>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.ClearScript">
      <Version>6.0.2</Version>
      <PrivateAssets>contentFiles;analyzers</PrivateAssets>
    </PackageReference>
  </ItemGroup>
...

NuSpec file

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>ClassLibrary1</id>
    <version>0.0.0.1</version>
    <authors>DotNetDeveloper</authors>
    <owners>DotNetDeveloper</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package Description</description>
    <dependencies>
      <group targetFramework=".NETFramework4.8">
        <dependency id="Microsoft.ClearScript" version="6.0.2" exclude="Analyzers" />
        <dependency id="Newtonsoft.Json" version="12.0.3" exclude="Build,Analyzers" />
      </group>
    </dependencies>
    <frameworkAssemblies>
      <frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework=".NETFramework4.8" />
      <frameworkAssembly assemblyName="System.Core" targetFramework=".NETFramework4.8" />
      <frameworkAssembly assemblyName="System.Data.DataSetExtensions" targetFramework=".NETFramework4.8" />
      <frameworkAssembly assemblyName="System.Data" targetFramework=".NETFramework4.8" />
      <frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.8" />
      <frameworkAssembly assemblyName="System.Net.Http" targetFramework=".NETFramework4.8" />
      <frameworkAssembly assemblyName="System.Xml" targetFramework=".NETFramework4.8" />
      <frameworkAssembly assemblyName="System.Xml.Linq" targetFramework=".NETFramework4.8" />
    </frameworkAssemblies>
    <contentFiles>
      <files include="any/net48/Lookup/TextFile1.txt" buildAction="Content" copyToOutput="true" />
    </contentFiles>
  </metadata>
</package>

Side notes

  1. Don't forget to delete the cache from ~\.nuget\packages\classlibrary1 before you build the ConsoleApp1.csproj each time. (library.xml takes care of it, you only have to do it manually if you are using VS directly)
rainersigwald commented 4 years ago

@sujitnayak, what's the best venue for this question?

sujitnayak commented 3 years ago

For a C# project referencing the Microsoft.ClearScript package (version 7.1.0) I don't see any difference in ClickOnce publishing output between 4.7.2 and 4.8. The following 4 ClearScript files get published for both:

ClearScript.Core.dll.deploy ClearScript.V8.dll.deploy ClearScript.Windows.Core.dll.deploy ClearScript.Windows.dll.deploy