Yasir
Yasir

Reputation: 1

Publish Angular 2 Webpack using VisualStudio 2015

How to publish angular 2 with Webpack using VS 2015... I'am trying to publish an angular 2 with webpack application developed in VS 2015. I tried the Publish Profile with Webdeploy selected. But its giving me an error:

Copying file dist\app.c5115b00bf67c961f449.css.map to obj\Release\Package\PackageTmp\dist\app.c5115b00bf67c961f449.css.map failed. Could not find file 'dist\app.c5115b00bf67c961f449.css.map'.

can any one tell me the correct process to deploy/publish angular 2 app with webpack using VS 2015. I choosed the ASP.NET empty project for this application. The project is setup using the Quick Start at here

Upvotes: 0

Views: 589

Answers (1)

Andrew Anderson
Andrew Anderson

Reputation: 143

Have you looked in your Dist to see if that file exists? Make sure to look at the hash. That is auto generated. Also below are the steps I was able to use to publish Angular2 to a windows box.

  1. You should not include your DIST files with your project(this will be included later, the issue you will have is the Hash changes that is why you have the error)
  2. Inside your publish profile(prd.pubxml) You need to add the following lines in the first Property Group. This is optional is just does not publish files/folders you do not need

    <ExcludeFoldersFromDeployment>insert folders here not needed for deployment separated by ;</ExcludeFoldersFromDeployment> <ExcludeFilesFromDeployment>inset file names here not needed for deployment seperate by ;</ExcludeFilesFromDeployment>

Paste the following code after the first Property Group in the same file.

<Target Name="DistFiles">
    <ItemGroup>
      <_CustomFiles Include="dist\**\*" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
  <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      DistFiles;
      ;
    </CopyAllFilesToSingleFolderForPackageDependsOn>
    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      DistFiles;
      ;
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>  
  </PropertyGroup>

This will deploy the dist files regardless of the hash key. Notice the line "CustomFiles Includes" This grabs all files and folders in the Dist

Upvotes: 1

Related Questions