I assume you're trying to modify the auto-generated assemblyinfo file in your SDK project. Your Target is configured to run after the build which is far too late. The assemblyinfo file is generated before the build starts so you'd need to hook into the build after it is generated but before the build itself.
However in your case all you're doing is modifying the assembly metadata. You don't need a build task for that. Set the properties using a standard
PropertyGroup. Inside the group set the assembly metadata attributes and the auto-generated assembly info file will pick them up. The
directory.build.props file is the ideal place to do this for solution-wide settings. You can configure the properties there and all assemblies will use those settings.
xml <Project> <PropertyGroup> <Product>My Product</Product> <Company>My Company</Company> </PropertyGroup> </Project>
The only time you'd need to do a custom target is if you wanted to add additional metadata that is not currently supported by the auto-generate task. Again though you can do that using a
directory.build.targets file instead. Since this is adding assembly metadata though you should be able to just add it and let it run normally which should be early in the build process. At most you would probably specify a before targets of
xml <Target BeforeTargets="BeforeCompile"> </Target>
In your pre-build task it looks like you're trying to get the assembly title property that you defined in the target file. That isn't going to work because MSBuild has already captured the environment variables by the time your target runs. But note that your target isn't actually setting AssemblyTitle, the MSBuild property. It is telling MSBuild to generate an assembly attribute of type AssemblyTitle and setting its value. There is no MSBuild property definition here.
To set the
AssemblyTitleMSBuild property you need to wrap the MSBuild property with the
PropertyGroupelement. This is how MSBuild properties are set/changed in MSBuild. This has nothing to do with assembly attributes. They are completely different things.
Targetto explicitly set
PropertyGroupto the value you want. Then try to read the MSBuild property in your pre-build event. To be honest I've never went that route before so I don't know if the pre-build event is going to see the updated value. The property must be set before compilation though. After compilation it is too late.