Pulkit Sharma
Pulkit Sharma

Reputation: 324

App.Config not found when packaging single project console app as an executable using MSBuild 'package' target

When Running a console app packaged to a single .exe with msbuild I appear to be unable to access my app.config resulting in the binding redirect errors similar to

LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/sharmapulkit/Downloads/WebJobs/PackageTmp/bin/Microsoft.Bcl.AsyncInterfaces.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\sharmapulkit\Downloads\WebJobs\PackageTmp\bin\Microsoft.Bcl.AsyncInterfaces.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

When I run msbuild /t:package "C:\Users\sharmapulkit\source\Practice\App\src\ccm\WebJob\WebJob\WebJobs.csproj" /p:BuildType="retail" /p:BuildArchitecture="amd64" /p:Platform="x64" /p:Configuration="release" I can the WebJobs.exe.config file in the release folder but not in the package/packegeTmp/bin. It seems like msbuild 'package' target is not adhering the app config in the project WebJobs.csproj.

This is the project file at the high level

     <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>WebJobs</RootNamespace>
        <AssemblyName>WebJobs</AssemblyName>
        <TargetFramework>net472</TargetFramework>
        <DeployDefaultTargetFrameworkVersion>4.7.2</DeployDefaultTargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
     
 <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
        <BinariesBuildTypeArchDirectory>$(REPOROOT)\out\$(BuildType)-$(BuildArchitecture)\</BinariesBuildTypeArchDirectory>
        <OutputPath>$(BinariesBuildTypeArchDirectory)\$(AssemblyName)</OutputPath>
        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
        <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
        <NoWarn>MSB3836</NoWarn>
      </PropertyGroup>
    
      <ItemGroup>
        <None Include="app.config" />
      </ItemGroup>
</Project>

Am I missing some way of setting the project as the start up rather than the program class? How can I get the executable to find the app.config?

Upvotes: 0

Views: 27

Answers (0)

Related Questions