Skip to content

Commit

Permalink
Create the 'out' directory before restoring packages
Browse files Browse the repository at this point in the history
This makes it easier to guarantee the path always exists so msbuild
/t:Restore more reliably succeeds.

Don't rely on running the 'pack' command to create the directory.
  • Loading branch information
alanmcgovern committed Jul 17, 2024
1 parent f13316f commit 43108ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<CI Condition="'$(CI)' == '' ">false</CI>

<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<!-- this is also in src/Directory.Build.props -->
<Out Condition=" '$(Out)' == '' ">$(MSBuildThisFileDirectory)out</Out>

<MSBuildCommonProperties>$(MSBuildCommonProperties);Deterministic=true</MSBuildCommonProperties>
Expand Down Expand Up @@ -39,7 +40,6 @@
</Target>

<Target Name="Pack">
<MakeDir Directories="$(Out)" />
<MSBuild
Projects="@(PackFile)"
Properties="$(MSBuildCommonProperties);Configuration=%(PackFile.Configuration);PackageOutputPath=$(Out)"
Expand Down
4 changes: 3 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
<Deterministic>true</Deterministic>
<RestorePackagesWithLockFile>false</RestorePackagesWithLockFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>


<Out Condition=" '$(Out)' == ''">$(MSBuildThisFileDirectory)..\out</Out>

<!-- These are essentially junk if i'm compiling against net472/NetStandard2.0 and newer targets.
Most rules result in uncompilable net472 code, so let's ignore them as i don't want to wade
through fixing/ignoring hundreds of rules with little real-world value. -->
Expand Down
4 changes: 4 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<PackageReference Update="System.Memory" Version="$(SystemMemoryVersion)" />
</ItemGroup>

<Target Name="CreateOutDirectory" BeforeTargets="_GetAllRestoreProjectPathItems;Restore;BeforeResolveReferences;CollectPackageReferences">
<MakeDir Directories="$(Out)" />
</Target>

<Target Name="SetAssemblyVersion" BeforeTargets="GetAssemblyVersion" Condition="'$(RestoreSuccess)' != 'true' Or '$(Configuration)' == 'Debug' Or '$(GitInfoVersion)' == '' ">
<PropertyGroup>
<Version>0.0.0.1</Version>
Expand Down

0 comments on commit 43108ed

Please sign in to comment.