0

My CSPROJ looks like this, however I am not able to find the exe being packed in the lib or elsewhere. How can I pack the executable of my console app?

THe current nuget doesn't have dependencies and self sutained with all the referenced dll's but the executable is missing.

<Project Sdk=".NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <RootNamespace>Annotation</RootNamespace>
        <AssemblyName>Annotation.AnnotationClient</AssemblyName>
        <EnableNETAnalyzers>true</EnableNETAnalyzers>
        <AnalysisLevel>latest</AnalysisLevel>
        <PackageType>DotnetTool</PackageType>
    </PropertyGroup>

    <ItemGroup>
        <AdditionalFiles Include="..\stylecop.json" />
    </ItemGroup>

    <PropertyGroup Condition="'$(Configuration)' == 'Release'">
        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    </PropertyGroup>
    
    <ItemGroup>
      <Content Include="..\AnnotationHandler\AnnotationSchema.json" Link="AnnotationSchema.json">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        <PackageCopyToOutput>true</PackageCopyToOutput>
        <PackagePath>$(BuildOutputTargetFolder)\$(TargetFramework)</PackagePath>
      </Content>
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include=".Identity.Client" Version="4.41.1" PrivateAssets="All" />
        <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20158.1" PrivateAssets="All" />
    </ItemGroup>

    <ItemGroup>
        <ProjectReference Include="..\AnnotationHandler\AnnotationHandler.csproj" PrivateAssets="All" />
    </ItemGroup>

    <ItemGroup>
      <None Update="App.config">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      </None>
    </ItemGroup>
    
    <PropertyGroup>
        <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
        <AllowedOutputExtensionsInPackageBuildOutputFolder>
            $(AllowedOutputExtensionsInPackageBuildOutputFolder);.xml
            $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
        </AllowedOutputExtensionsInPackageBuildOutputFolder>
    </PropertyGroup>
    <Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveAssemblyReferences">
        <ItemGroup>
            <BuildOutputInPackage Include="@(ReferenceCopyLocalPaths)" />
        </ItemGroup>

        <!-- Print batches for debug purposes -->
        <Message Text="Batch for .nupkg: ReferenceCopyLocalPaths = @(_ReferenceCopyLocalPaths), ReferenceCopyLocalPaths.DestinationSubDirectory = %(_ReferenceCopyLocalPaths.DestinationSubDirectory) Filename = %(_ReferenceCopyLocalPaths.Filename) Extension = %(_ReferenceCopyLocalPaths.Extension)" Importance="High" Condition="'@(_ReferenceCopyLocalPaths)' != ''" />

    </Target>
</Project>

  • Answer https://stackoverflow.com/a/55775370/4870358 – Marcus Höglund Aug 11 '22 at 06:55
  • Hi , Marcus Höglund and others, I did not get much leads from above link. I dont want to use dotnet cli to run my app and want to include the exe in my package. I can see the exe generated in release , debug builds and even with publish. But pack fails to include the exe. Is it with cs project ? – sreeni rau Aug 11 '22 at 21:28
  • Basically Nuget is for distributing class libraries, not executables. Read this https://stackoverflow.com/a/48100753/4870358 – Marcus Höglund Aug 12 '22 at 05:47
  • I think we can manually create using Nuspec and while I get nugets are for class library distribution , to maintain some pipelines , I need to package an console app executable. So far based on my reading , I found dotnet tools approach to package executables but looking to see if I can manually pack the executable. Any more suggestions are welcome – sreeni rau Aug 14 '22 at 18:42

0 Answers0