Open geirsagberg opened 7 years ago
I use the same technique for my json configuration files generation. You could move your types into a separate class library and reference that instead.
Good idea, I'll give that a shot :)
Works like a charm, thanks!
It still might be a good idea for Scripty to provide an option to run the task post project build.
I agree - it's not a bad idea at all. I just don't know enough about MSBuild tasks to toggle where in the process a task occurs based on a flag. Will need to research before I can implement (or take a PR).
There is a target named AfterBuild
that might be used conditionally, based on a property perhaps?
Reference: https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-targets
AfterBuild
seems to only allow one task though; I think maybe DependsOnTargets
or AfterTargets
might be appropriate: https://docs.microsoft.com/en-us/visualstudio/msbuild/target-build-order
@geirsagberg , @TylerBrinkley ,
Can you share your working solution?
For me:
1) I had to add in .csx file #r "bin\\Debug\\MY_DLL.dll"
! (I don't like this)
2) Whenever I do Rebuild/Clean scripty task throws an Exception that the dll was not found. I have to change/touch file and do Build (not rebuild). (I hate this)
Tell me you have a solution to this!
The following worked for me:
MyApp.Data
#r "../MyApp.Data/bin/debug/MyApp.Data.dll"
Now obviously you will run into trouble if you are building in release mode. So maybe add a post build task to the class library that copies the DLL to a better location.
Haven't tried this myself, but this might get you started: https://docs.microsoft.com/en-us/cpp/build/how-to-use-build-events-in-msbuild-projects
When using this method I always set my build directory to just /bin for both debug and release to prevent any issues.
I am unsure if you are trying to reference a .dll of the same project that the script is in, I am only able to get this error when doing so.
Which IMHO you shouldn't be doing anyway, as you will always need to rebuild the project to contain the models you've just generated, this will cause a recursive dependency.
Try separating the script into another library and reference that .dll file.
Or am I wrong?
I am using Scripty.MsBuild to generate TypeScript typings in a ASP.NET Core 2.0 project quite successfully, by referencing the output DLL in the bin folder. However, this doesn't work if the project is not built; also, I have to build twice in order to pick up changes.
Is there any way to run the MsBuild task after the project itself is built (and the DLL will be available in the bin folder?)