Skip to content

Commit

Permalink
Remove redundancies for BuildFromSource fix (#2017)
Browse files Browse the repository at this point in the history
* Prevent unnecessary restore for build from source scenario.
  • Loading branch information
singhsarab authored May 16, 2019
1 parent 7909f50 commit 402060b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
20 changes: 13 additions & 7 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,18 @@ function restore_package()
log "restore_package: Start restoring packages to $TP_PACKAGES_DIR."
local start=$SECONDS

log ".. .. Restore: Source: $TP_ROOT_DIR/src/package/external/external.csproj"
$dotnet restore $TP_ROOT_DIR/src/package/external/external.csproj --packages $TP_PACKAGES_DIR -v:minimal -warnaserror -p:Version=$TPB_Version || failed=true
if [ "$failed" = true ]; then
error "Failed to restore packages."
return 2
fi
if [[ $TP_USE_REPO_API = 0 ]]; then
log ".. .. Restore: Source: $TP_ROOT_DIR/src/package/external/external.csproj"
$dotnet restore $TP_ROOT_DIR/src/package/external/external.csproj --packages $TP_PACKAGES_DIR -v:minimal -warnaserror -p:Version=$TPB_Version || failed=true
else
log ".. .. Restore: Source: $TP_ROOT_DIR/src/package/external/external_BuildFromSource.csproj"
$dotnet restore $TP_ROOT_DIR/src/package/external/external.csproj --packages $TP_PACKAGES_DIR -v:minimal -warnaserror -p:Version=$TPB_Version -p:DotNetBuildFromSource=true || failed=true
fi

if [ "$failed" = true ]; then
error "Failed to restore packages."
return 2
fi

log "restore_package: Complete. Elapsed $(( SECONDS - start ))s."
}
Expand All @@ -244,7 +250,7 @@ function invoke_build()
if [[ $TP_USE_REPO_API = 0 ]]; then
$dotnet build $TPB_Solution --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild -p:LocalizedBuild=$TPB_LocalizedBuild || failed=true
else
$dotnet build $TPB_Build_From_Source_Solution --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild -p:LocalizedBuild=$TPB_LocalizedBuild || failed=true
$dotnet build $TPB_Build_From_Source_Solution --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild -p:LocalizedBuild=$TPB_LocalizedBuild -p:DotNetBuildFromSource=true || failed=true
fi
else
find . -name "$PROJECT_NAME_PATTERNS" | xargs -L 1 $dotnet build --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild -p:LocalizedBuild=$TPB_LocalizedBuild
Expand Down
18 changes: 10 additions & 8 deletions src/package/external/external.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<CopyBuildOutputToPublishDirectory>false</CopyBuildOutputToPublishDirectory>
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(DotNetBuildFromSource)' != 'true' ">
<!-- This csproj restore external tools required for build process -->
<PackageReference Include="NuGet.CommandLine">
<Version>3.4.3</Version>
Expand All @@ -49,13 +49,6 @@
<Version>1.1.0-beta1-62316-01</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<!-- Required for resolution of desktop dependencies in non windows environment.
We've to set to net46 since the net451 and other packages have assemblies in wrong case.
E.g. System.XML instead of System.Xml. -->
<PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.6">
<Version>1.0.1</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Internal.TestPlatform.Extensions">
<Version>$(TestPlatformExternalsVersion)</Version>
<PrivateAssets>All</PrivateAssets>
Expand Down Expand Up @@ -88,6 +81,15 @@
<Version>15.6.815-master284DF69C</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<!-- Required for resolution of desktop dependencies in non windows environment.
We've to set to net46 since the net451 and other packages have assemblies in wrong case.
E.g. System.XML instead of System.Xml. -->
<PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.6">
<Version>1.0.1</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand Down

0 comments on commit 402060b

Please sign in to comment.