Exclude transferred / nonexistent .JS files from TypeScript Web Publish

When the web tries to publish a TypeScript project in Visual Studio 2015, Update 2; assembly completed successfully, but package / publish fails:

Error: Copying file typescript-filename.js to obj\Release\Package\PackageTmp\typescript-filename.js failed. Could not find file 'typescript-filename.js'.

An error occurs when a project specifies a directory for TypeScript intermediate / output files. To reproduce this error, simply create a file tsconfig.jsonin the root directory of the Visual Studio TypeScript HTML Application project with the following contents:

{
    "compilerOptions": {
        "outDir": "transpiled"
    }
}

If you do not use the outDirintermediate / output directory option , I can publish my source files, which I do not want. (Also, the output of the project is mixed with the source, and the project becomes a mess.)

How can I exclude these TypeScript redirected files from a package / publication?

WebPack JJ- ( /), , .


:

.TS , None/Do not copy. :

"None" "TypeScript Compile" ( ) .TS , .TS/.JS ; , , , . .JS.

, , voodoo, , , .

-, C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Transform\Microsoft.Web.Publishing.AspNetCompileMerge.targets 615 , (AFAIK) @(FilesForPackagingFromProject). .TS .JS, , , .

<CopyPipelineFiles PipelineItems="@(FilesForPackagingFromProject)"
                       SourceDirectory="$(WebPublishPipelineProjectDirectory)"
                       TargetDirectory="$(_PreAspnetCompileMergeSingleTargetFolder)"
                       SkipMetadataExcludeTrueItems="True"
                       UpdateItemSpec="True"
                       DeleteItemsMarkAsExcludeTrue ="True">
+4
3
0

, , :

  • .targets, ( )

  • node xml, :

    <Target Name="CustomExcludeFiles" 
          DependsOnTargets="$(ExcludeFilesFromPackageDependsOn)"
          BeforeTargets="ExcludeFilesFromPackage">
    
    <Message Text="Custom exclude..." Importance="high"></Message>
    <WriteLinesToFile Condition="$(EnablePackageProcessLoggingAndAssert)"
                      Encoding="utf-8"
                      File="$(PackageLogDir)\CustomExcludeFilesBefore.txt"
                      Lines="@(FilesForPackagingFromProject->'
                      From:%(Identity) 
                      DestinationRelativePath:%(DestinationRelativePath) 
                      Exclude:%(Exclude) 
                      FromTarget:%(FromTarget) 
                      Category:%(Category)
                      ProjectFileType:%(ProjectFileType)')" Overwrite="True" />
    
    <ItemGroup>
      <FilesForPackagingFromProject Remove="@(FilesForPackagingFromProject)" Condition="!Exists('%(FullPath)')" />
    </ItemGroup>
    <WriteLinesToFile Condition="$(EnablePackageProcessLoggingAndAssert)"
                      Encoding="utf-8"
                      File="$(PackageLogDir)\CustomExcludeFilesAfter.txt"
                      Lines="@(FilesForPackagingFromProject->'
                      From:%(Identity) 
                      DestinationRelativePath:%(DestinationRelativePath) 
                      Exclude:%(Exclude) 
                      FromTarget:%(FromTarget) \
                      Category:%(Category)
                      ProjectFileType:%(ProjectFileType)')" Overwrite="True"/>
    </Target>
    
    1. , Visual Studio
+4

MSBuild:

<ItemGroup>  
  <ExcludeFromPackageFiles Include="Sample.Debug.xml">  
    <FromTarget>Project</FromTarget> 
  </ExcludeFromPackageFiles> 
</ItemGroup> 

Sayed blog :

http://sedodream.com/2010/08/15/WebDeploymentToolMSDeployHowToExcludeFilesFromPackageBasedOnConfiguration.aspx

0

All Articles