lorandbiro / octopack.precompile Goto Github PK
View Code? Open in Web Editor NEWA NuGet package that adds an ASP.NET precompile step to the build just before OctoPack is called.
License: MIT License
A NuGet package that adds an ASP.NET precompile step to the build just before OctoPack is called.
License: MIT License
We are using msbuild with output to different directory by specifying /p:OutDir="$binariesPath".
&"c:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" WebApplication1.sln /target:Rebuild /p:RunOctoPack=true /p:OutDir="$binariesPath\"
It causes OctoPack.Precompile.targets to fail:
"C:\GitReposD\OctoPack.Precompile\Source\Test\WebApplication1\WebApplication1\WebApplication1.csproj" (Rebuild target) (2) ->
(OctoPackPrecompile target) ->
C:\GitReposD\OctoPack.Precompile\Source\OctoPack.Precompile.targets(45,24): error MSB4184: The expression ""C:\GitReposD\OctoPack.Precompile\Source\Binaries\roslyn\csc.exe".Substring(77)" cannot be evaluated. startIndex cannot be larger than length of string. Parameter name: startIndex [C:\GitReposD\OctoPack.Precompile\Source\Test\WebApplication1\WebApplication1\WebApplication1.csproj]
The problem is that msbuild command assumes that files have the same prefix as ProjectDir
<!--
Some of the collected file paths are full paths, but we need paths relative to the project so we can perform a recursive copy.
Also it looks like NuGet doesn't like the packages.config inside the packages, so we skip it.
http://help.octopusdeploy.com/discussions/problems/29208-packagesconfig-files-are-excluded-from-packages-created-by-octopack
-->
<NormalizedFiles Include="@(CollectedFiles->'%(FullPath)'->Substring($(ProjectDir.Length)))" Exclude="packages.config" />
Could you please suggest how to change the target to use OutDir (I haven't work with MSBuild for a while)?
You can see full test script in my fork https://github.com/MNF/OctoPack.Precompile/blob/master/Source/Test-OutDir.ps1
As part of the precompilation process, the OctoPack.Precompile.targets
file has a NormalizedFiles
step which takes all of the collected files and makes the paths relative to the project.
This works great until one of your included files is a linked file.
The script to perform the conversion is:
"@(CollectedFiles->'%(FullPath)'->Substring($(ProjectDir.Length)))
This assumes that the collected file resides in the project directory, and would work for the following include:
<Content Include="Locale\Web.config" />
but would not work for:
<Content Include="..\Web.Shared\Content\bootstrap-custom\css\bootstrap-theme.min.css">
<Link>Content\bootstrap-custom\css\bootstrap-theme.min.css</Link>
</Content>
as the length of the path containing directory is different to ProjectDir.Length.
An example compiler error:
C:\[Redacted Path]\packages\OctoPack.Precompile.2.0.1\build\OctoPack.Precompile.targets(51,5): error MSB3030: Could not copy the file "nt\bootstrap-custom\css\bootstrap-theme.min.css" because it was not found. [[Redacted Path]]
Please could you advise if you're aware for a workaround to this? I'd love to use your library.
We have a solution that contains several different projects. Only one of these projects needs to be precompiled prior to packaging by OctoPack. During the processing carried out by OctoPack.Precompile, a list of NormalizedFiles
is created, from the @(CollectedFiles)
. However, this line in the OctoPack.Precompile.targets
file is, I think, inadvertently truncating paths that are outside the project folder heirarchy:
<DestinationPath>$(OctoPackPrecompileIntermediateOutputPath)$([System.String]::Copy('%(FullPath)').Substring($(ProjectDir.Length)))</DestinationPath>
For example, my .csproj
is dependent on other projects within our solution, and has project references such as:
<ProjectReference Include="..\DSSCommon\DSSCommon.csproj">
<Project>{1606CFDC-D60A-4920-8FEB-E5C09168AA54}</Project>
<Name>DSSCommon</Name>
</ProjectReference>
This results in files being copied into a directory such as obj\Release\PrecompiledIntermediate\mmon
. I suspect the use of $(ProjectDir.Length)
when making a relative path is the cause of this issue.
OctoPack.Precompile is erroneously copying files to the intermediate working directory, when those files have the metadata Exclude=true
set
First of all really nice work with this.
I want to ask if it would be possible to force the Precompile to use the aspnet_compiler.exe from a diffrent path.
So for example if needed you can use the x64 version of it.
I tried this without the Precompile package and it works ok.
"PropertyGroup
AspnetCompilerPath$(windir)\Microsoft.NET\Framework64\v4.0.30319 /AspnetCompilerPath
/PropertyGroup"
but can't make it work with the package.
any help it is appreciated
First of all, this is a great package! thank you so much!
It would be perfect if we could also add support for AspNet_Merge.
This would create a single assembly to be added in the bin folder.
Some version numbers for context:
Finished for the week but will investigate when I get a chance.
Originally posted by @benmccallum in #8 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.