title: Files not available on server for sending to the client
body: <p>I am having a weird issue in an ASPNET Core Web API:</p>
  
  <p>The API is proving an excel template in order to allow the user to fill the data and upload to the system. 
  This excel template is inside the project, and the access to the file is managed by a Resources file (resx) because there are different files depending on the culture</p>
  
  <p>Locally, as the known topic, is working without any problem, however, once is deployed, this download template is failing, the error in the logs is the following:</p>
  
  <blockquote>
    <p>EXCEPTION MESSAGE: Unable to cast object of type 'System.String' to type 'System.Byte[]'.                     </p>
  </blockquote>
  
  <p>Here is how the file is managed in csproj:</p>
  
  <pre><code>&lt;ItemGroup&gt;
      &lt;None Remove="Resources\Templates\ImportTemplate-fr-FR.xlsx" /&gt;
      &lt;None Remove="Resources\Templates\ImportTemplate.xlsx" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;ItemGroup&gt;
      &lt;EmbeddedResource Include="Resources\Templates\ImportTemplate-fr-FR.xlsx" /&gt;
      &lt;EmbeddedResource Include="Resources\Templates\ImportTemplate.xlsx" /&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>Here is how the file is retrieved by resx file:</p>
  
  <pre><code>_documentExcelImportService.GetTemplate(Resources.ImportExcelTemplate);
  </code></pre>
  
  <p>I also tried with "Copy always", with same result</p>
  
  <p>As a note, we are deploying the application to a local server, and also to an Azure AppService</p>
  
  <p>Any idea?</p>
  
  <p>Thank you in advance</p>
  
  <p><strong>UPDATE A</strong> (yolo sora question):</p>
  
  <p>GetTemplate Is retrieving a byte array directly and encapsulate with more info inside a DTO, the resx is automatically managing this:</p>
  
  <pre><code>public Document GetTemplate(byte[] resourceByteArray)
  {            
      return new Document
      {
          FileName = GetFullFileName(),
          FileBlob = resourceByteArray,
          CreationDate = DateTime.Now,
      };
  }
  </code></pre>
  
  <p><strong>UPDATE B</strong></p>
  
  <p>Having a deeply check on the log, I can found that when is trying to access to the Resources file (resx), is going to a physical path that it was created in the Azure agent server where the pipeline compiled it. Is quite weird, but, as soon as I have seen, I tried to publish manually, and with this manual build, it works! </p>
  
  <p>So seems to be a problem with how is managing the Resources files or the references...</p>
  
  <p>Ideas?</p>