Skip to content

Commit 402060b

Browse files
authored
Remove redundancies for BuildFromSource fix (#2017)
* Prevent unnecessary restore for build from source scenario.
1 parent 7909f50 commit 402060b

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

scripts/build.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,18 @@ function restore_package()
218218
log "restore_package: Start restoring packages to $TP_PACKAGES_DIR."
219219
local start=$SECONDS
220220

221-
log ".. .. Restore: Source: $TP_ROOT_DIR/src/package/external/external.csproj"
222-
$dotnet restore $TP_ROOT_DIR/src/package/external/external.csproj --packages $TP_PACKAGES_DIR -v:minimal -warnaserror -p:Version=$TPB_Version || failed=true
223-
if [ "$failed" = true ]; then
224-
error "Failed to restore packages."
225-
return 2
226-
fi
221+
if [[ $TP_USE_REPO_API = 0 ]]; then
222+
log ".. .. Restore: Source: $TP_ROOT_DIR/src/package/external/external.csproj"
223+
$dotnet restore $TP_ROOT_DIR/src/package/external/external.csproj --packages $TP_PACKAGES_DIR -v:minimal -warnaserror -p:Version=$TPB_Version || failed=true
224+
else
225+
log ".. .. Restore: Source: $TP_ROOT_DIR/src/package/external/external_BuildFromSource.csproj"
226+
$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
227+
fi
228+
229+
if [ "$failed" = true ]; then
230+
error "Failed to restore packages."
231+
return 2
232+
fi
227233

228234
log "restore_package: Complete. Elapsed $(( SECONDS - start ))s."
229235
}
@@ -244,7 +250,7 @@ function invoke_build()
244250
if [[ $TP_USE_REPO_API = 0 ]]; then
245251
$dotnet build $TPB_Solution --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild -p:LocalizedBuild=$TPB_LocalizedBuild || failed=true
246252
else
247-
$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
253+
$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
248254
fi
249255
else
250256
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

src/package/external/external.csproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<CopyBuildOutputToPublishDirectory>false</CopyBuildOutputToPublishDirectory>
2424
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>
2525
</PropertyGroup>
26-
<ItemGroup>
26+
<ItemGroup Condition=" '$(DotNetBuildFromSource)' != 'true' ">
2727
<!-- This csproj restore external tools required for build process -->
2828
<PackageReference Include="NuGet.CommandLine">
2929
<Version>3.4.3</Version>
@@ -49,13 +49,6 @@
4949
<Version>1.1.0-beta1-62316-01</Version>
5050
<PrivateAssets>All</PrivateAssets>
5151
</PackageReference>
52-
<!-- Required for resolution of desktop dependencies in non windows environment.
53-
We've to set to net46 since the net451 and other packages have assemblies in wrong case.
54-
E.g. System.XML instead of System.Xml. -->
55-
<PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.6">
56-
<Version>1.0.1</Version>
57-
<PrivateAssets>All</PrivateAssets>
58-
</PackageReference>
5952
<PackageReference Include="Microsoft.Internal.TestPlatform.Extensions">
6053
<Version>$(TestPlatformExternalsVersion)</Version>
6154
<PrivateAssets>All</PrivateAssets>
@@ -88,6 +81,15 @@
8881
<Version>15.6.815-master284DF69C</Version>
8982
<PrivateAssets>All</PrivateAssets>
9083
</PackageReference>
84+
</ItemGroup>
85+
<ItemGroup>
86+
<!-- Required for resolution of desktop dependencies in non windows environment.
87+
We've to set to net46 since the net451 and other packages have assemblies in wrong case.
88+
E.g. System.XML instead of System.Xml. -->
89+
<PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.6">
90+
<Version>1.0.1</Version>
91+
<PrivateAssets>All</PrivateAssets>
92+
</PackageReference>
9193
<Reference Include="System" />
9294
<Reference Include="Microsoft.CSharp" />
9395
</ItemGroup>

0 commit comments

Comments
 (0)