Sdk: Produce outputs on build is removed from RC2 and PostCompile does not work as expected

Created on 17 May 2016  路  6Comments  路  Source: dotnet/sdk

In RC1 (dnx) you could check the option "Produce outputs on build" which creates a NuGet after the build.

However in RC2 (dotnet) this does not work anymore, and the postcompile cannot be use for that.

I've defined this in my project.json:

"scripts": {
        "postcompile": [ "dotnet pack --no-build --version-suffix %project:Version% project.json" ]
    },

However this step is executed for every framework in my projoct.json ?

1>      0 Error(s)
1>  Time elapsed 00:00:01.9413921
1>   (The compilation time can be improved. Run "dotnet build --build-profile" for more information)
1>  Project Linq.PropertyTranslator.Core (.NETStandard,Version=v1.4) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
1>  Compiling Linq.PropertyTranslator.Core for .NETStandard,Version=v1.4
1>  Producing nuget package "Linq.PropertyTranslator.Core.1.0.2-1.0.2" for Linq.PropertyTranslator.Core
1>  Linq.PropertyTranslator.Core -> C:\Projects\GitHub\Linq.PropertyTranslator.Core\src\Linq.PropertyTranslator.Core\bin\Debug\Linq.PropertyTranslator.Core.1.0.2-1.0.2.nupkg
1>  Producing nuget package "Linq.PropertyTranslator.Core.1.0.2-1.0.2.symbols" for Linq.PropertyTranslator.Core
1>  Linq.PropertyTranslator.Core -> C:\Projects\GitHub\Linq.PropertyTranslator.Core\src\Linq.PropertyTranslator.Core\bin\Debug\Linq.PropertyTranslator.Core.1.0.2-1.0.2.symbols.nupkg
1>  Compilation succeeded.
1>      0 Warning(s)
1>      0 Error(s)
1>  Time elapsed 00:00:01.9015257
1>   (The compilation time can be improved. Run "dotnet build --build-profile" for more information)
1>  Project Linq.PropertyTranslator.Core (.NETStandard,Version=v1.5) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
1>  Compiling Linq.PropertyTranslator.Core for .NETStandard,Version=v1.5
1>  Producing nuget package "Linq.PropertyTranslator.Core.1.0.2-1.0.2" for Linq.PropertyTranslator.Core
1>  Linq.PropertyTranslator.Core -> C:\Projects\GitHub\Linq.PropertyTranslator.Core\src\Linq.PropertyTranslator.Core\bin\Debug\Linq.PropertyTranslator.Core.1.0.2-1.0.2.nupkg
1>  Producing nuget package "Linq.PropertyTranslator.Core.1.0.2-1.0.2.symbols" for Linq.PropertyTranslator.Core
1>  Linq.PropertyTranslator.Core -> C:\Projects\GitHub\Linq.PropertyTranslator.Core\src\Linq.PropertyTranslator.Core\bin\Debug\Linq.PropertyTranslator.Core.1.0.2-1.0.2.symbols.nupkg
1>  Compilation succeeded.
1>      0 Warning(s)
1>      0 Error(s)
1>  Time elapsed 00:00:01.9287423

Most helpful comment

postbuild is not working in RC2, it never gets executed whereas postcompile does

All 6 comments

Instead of "postcompile" you should use "postpublish" or "postbuild" (if you'd like the package(s) to be created after each build).

postbuild is not working in RC2, it never gets executed whereas postcompile does

Yes, sadly postbuild does nothing. A possible workaround is to edit your .xproj file and add

<Target Name="AfterBuild">
  <Exec Command="dotnet pack"/>
</Target>

Maybe not that strange...

In the future all these things will maybe move to csproj so no worries...

Any fix for this yet?

@StefH had this right :) Preview3 moves this behavior to csproj and lets us use msbuild for build orchestration. Pack itself is now a target, making this sort of chaining even easier.

Was this page helpful?
0 / 5 - 0 ratings