1

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.
cilerler
  • 9,010
  • 10
  • 56
  • 91
  • @MickyD, please do not remove the tag [tag:nuget]; the issue only occurs when things come from the NuGet. If I create the file in the 2nd project, there is no issue. – cilerler Jul 04 '20 at 11:30

0 Answers0