-
Notifications
You must be signed in to change notification settings - Fork 1.1k
$(TargetPath) or $(TargetDir) are empty on PostBuild event on netstandard project #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
ProjectDir, OutDir, ProjectName don't work also |
Also ConfigurationName |
We will probably be disabling pre and post build events and recommend people use targets instead. For example: <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="echo Before Build: $(OutDir)" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="echo After Build: $(OutDir)" />
</Target> Closing this issue as a duplicate of #677. See also dotnet/project-system#1569 which is for updating the property pages in VS. |
Use PreBuild task / command-line GitVersion as a workaround (Windows only) dotnet/sdk#1055 (comment) Don't generate .nupkg on build
Where can we find these recommendations? I had to find it out the hard way after banging my head for hours why the events didn't work. |
…0191030.2 (dotnet#1055) - Microsoft.AspNetCore.Analyzers - 5.0.0-alpha1.19530.2 - Microsoft.AspNetCore.Mvc.Api.Analyzers - 5.0.0-alpha1.19530.2 - Microsoft.AspNetCore.Mvc.Analyzers - 5.0.0-alpha1.19530.2 - Microsoft.AspNetCore.Components.Analyzers - 5.0.0-alpha1.19530.2
This saved my day. The easiest solution is to remove |
Related: dotnet/try-convert#269 |
What do you mean by this @CaledoniaProject ? We have PostBuild events that use signtool.exe to sign assemblies from .NetFramework projects that were then run through the upgrade-assistant for VS2022/net6 targeting. Those no longer work presumably because many of the macros we use no longer exist in the SDK-style projects and/or VS2022.
What does "recreate the script in Visual Studio" mean exactly? |
It means to go to the project properties page, go to the build/events section, then paste in your pre-build and post-build events. It will create new targets for you like the following, as long as you delete the old
|
I have this... |
@krypt-lynx would a PropertyGroup with a CDATA section work? <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<PropertyGroup>
<PreBuildCommands><![CDATA[echo "pre-build"
git describe --tag --dirty --always > "$(ProjectDir)\git.txt"
cd "$(TargetDir)"
echo "target dir:"
echo "$(TargetDir)"
echo "current dir:"
cd
del /Q *.*]]></PreBuildCommands>
</PropertyGroup>
<Exec Command="$(PreBuildCommands)" />
</Target> |
Hi,
There's an issue with post build event on netstandard library.$(TargetDir) et $ (TargetPath) macros are empty while they are not empty on the "post build event command line" wizard on visual studio.
when executing a post build event, the
You can reproduce it easily by
creating a netstandard project library
put an echo "Target path is : " $(TargetPath)"
then build the project
take a look at output window
This works for $(SolutionDir) or other macros
The text was updated successfully, but these errors were encountered: