we have a project A (csproj, netstandard2.0) that we would like to release as a nuget package.
We want to use this package in project B using <packageReference> (csproj, .net framework 4.7.2) to speed up builds on our build server. Because we won't need to build project A before build of project B.
To ease development however i would like to have a solution that includes both projects, so that i can edit the source of project A and (re-)compile so that project B makes use of project A's latest version (without the need to pack a new nupkg of project A (and publish it on our nuget package source server if possible)). (While still using nuget on our build server)
How can this be archieved?
I searched the web and stackoverflow but couldn't find a way how this is intended to work.
Thanks
As @Zivkan says, this is a bit of an odd thing to do for a number of reasons, but if you want to try it, I think the following would work:
You could use a conditional statement in your project so that when built locally it uses a project reference, but when built on the build machine you specify a property in the command line to use a package reference instead.
e.g.
<Choose>
<When Condition="'$(IsBuildServer)' == 'true'">
<ItemGroup>
<PackageReference Include="A" Version="*" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<ProjectReference Include="relativepath\A.csproj" />
</ItemGroup>
</Otherwise>
</Choose>
And then when building on the build server, just make sure to specify -p:IsBuildServer=true
as a command line argument to msbuild / dotnet build.
The "*" in the package reference just means take the latest available stable package, but may not be exactly what you want depending on what exactly you want the build server to build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With