C
C#2y ago
swagrid

Run msbuild target only during dotnet pack

Is it possible to run a msbuild target in a csproj only when it's packaged to a nuget package, i.e. dotnet pack MyProject should cause the target to run while dotnet build MyProject shouldn't.
1 Reply
swagrid
swagrid2y ago
Hmm I have a target right now that looks like this
<Target Name="InstallNative" BeforeTargets="Pack" ...>
<Target Name="InstallNative" BeforeTargets="Pack" ...>
which isn't executed
<Target Name="InstallNative" BeforeTargets="Pack" Condition=" $(SkipNativeBuild) != 'true' ">
<Message Importance="high" Text=" ------------------------ Install --------------------------" />
<Exec Command="cmake --config $(Configuration) --install out/build/$(CMakeConfigPreset)" WorkingDirectory="$(NativeRootDir)" />
</Target>
<Target Name="InstallNative" BeforeTargets="Pack" Condition=" $(SkipNativeBuild) != 'true' ">
<Message Importance="high" Text=" ------------------------ Install --------------------------" />
<Exec Command="cmake --config $(Configuration) --install out/build/$(CMakeConfigPreset)" WorkingDirectory="$(NativeRootDir)" />
</Target>
removing the condition doesn't change anything that didn't help. but i just found out its my project properties. i do
<SkipCopyBuildProduct>true</SkipCopyBuildProduct>
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<GenerateDependencyFile>false</GenerateDependencyFile>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SkipCopyBuildProduct>true</SkipCopyBuildProduct>
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<GenerateDependencyFile>false</GenerateDependencyFile>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<IncludeBuildOutput>false</IncludeBuildOutput>
to not generate and package any dotnet assembly. but this seems to skip pack entirely yeah if i remove these properties the target runs
Want results from more Discord servers?
Add your server
More Posts
Fromfile is underlined not sure what I'm doingFor the second picture it states to "Make note of name of the folder where the images are saved and EF Core not fetching sub-entities by Id [Answered]I'm kinda new to EF Core so maybe the terminology is not right. I have the following models: PlayReplacing A Specific Colour of A WriteableBitmap [Answered]Good morning, I am currently working on a method that is meant to search a WriteableBitmap image forCompiler error [Answered]So im getting compiler error, i understand what it means but i dont know why i get it can you explai[EFCore] add many Parent entities with Child entities, How to connect them in single SaveChangesHello, im trying to sync data in my database with data in external source there is a example that i GroupBy cannot be translated usingHello I can't for example group data by month using one of class datetime attribute navigation propeMicrosoft.Xaml.Behaviors.Wpf MouseMove event passing event args to command is passing nullI have wpf application view. It is capturing MouseMove event, which is sending MouseEventArgs as theEnvironmental Variables in VS 2022 [Answered]```js { "profiles": { "Library.Dependency": { "commandName": "Project", "environmeNeed help getting cest timezonei currently have this code ```cs var timer = new PeriodicTimer(TimeSpan.FromSeconds(1)); wHei all, I am new to this Server and I realy need help on specific Problem [Answered]I am trying to move a .csv File from a Folder to another and it is actualy working but when I open t