You'll get flamed probably but I can relate (except it's a dear friend's husband).
Here's how I'm dealing with it...
Realising we probably would have made a nice couple had we met first but I love my friend and their kids more, affairs go against my moral compass and absolutely nothing can or will ever happen. Also meeting first would have been no guarantee of success or forever love. There are many options out there than are better than this. It's a shitty shitty option and getting closer even as "just as friends" won't add anything to mine, his, his wife or their kids' lives. How close do you have to be with your BIL, really? How close is it helpful to you to be?
Avoiding spending time with just him where possible...it had got to the point where we'd somehow always end up chatting away just the two of us at parties etc, as we share a lot of common interests, he ends up pouring me wine then it starts to feel more intimate and we might have a more in depth conversation than he's had with his wife that day or I've had with any man in a while. So now, the moment I realise other people have peeled off or it's ended up just the two of us I find somewhere else to be, seek out another female friend, make my excuses and leave early if I have to etc.
We share several interests/hobbies that my friend either is bored by or actively hates and actively encourages us to do together so she doesn't have to. I never ever take either of them up on the hint. Think they've got the point now when I've said, "No offence, Maggie, I know you love Dave and hate crowds but I don't want to go see Kings of Leon with someone else's husband!"
More difficult cos he's your BIL...but I've not let him have my phone number/way of contacting me even though he's tried to get it several times to send me a link or add me to an event on FB or something. If he has your number and he's sending you memes or sweet texts or whatever, either ignore or be very boring in your response, "ha! Just seen this!"
Focus my own love life. He's not the only man alive and he's not my soulmate. Neither is your BIL for you. For a start your BIL shouldn't be telling you you're beautiful and fawning over you, no matter how much he thinks those things. He should keep it all in his own head. You can either focus on your own marriage, be honest with DH about what you need and how those needs aren't being met and work together towards fixing things or break up and find a decent man who gives you the same feeling as BIL. You don't need to put up with a mediocre love life if you are so unhappy in your marriage.
I don't feed the whole "forbidden love", "I can't look at him or I might die from longing!", "why???why???No! We mustn't!" drama that can easily come about in these situations and feed the whole love/lust/limerence spiral cos none of that shit's real. I acknowledge the facts i.e "We make each other laugh. I like laughing with people." or "He makes me feel good about myself. Maybe my self-esteem is lacking." and even "It's a bit creepy the way he is always praising me to his guy friends. That's not fair on my friend. Yuck." Try and be as objective as you can. Facts over feelings.
I acknowledge that some of what I/we are feeling is completely hormonal. We're daft little monkeys whose bodies sometimes want to rule our minds and cause us to do things we'd massively regret and hurt other people through. Again, I notice it, acknowledge it and it passes quite quickly. "Ah. Lust. Thankfully I am an adult, know this will pass and have ways of dealing with this that don't involve fucking my brother in law" over, "OMG his arms are just...ugh...and his jaw is...I wonder what it would be like if we..." etc. Just don't go there. Don't feed the horny troll.
Whenever there's a moment of him praising me, doing something nice for me, telling me he "saw something and thought of me" etc...I acknowledge that this could all be him trying to boost his own ego and my reaction is quite powerful. I can either cause it to escalate or ignore it and decrease the likelihood of it happening. I know my friend is a bit sick of him at times and says things that knock his confidence (nothing horrible just, "Oh God, you are going on about that AGAIN. Look I'm tired and going to bed, can you put the bins out now because you will forget in the morning like you always do otherwise") and so he might be giving me some attention so I get all blushy and gushy and make him feel a bit better about his power to do so...I COULD get all blushy and gushy cos no one else is complimenting me but no matter wtf he does to try and get my attention I don't fall for it. No batting eyelashes and "oh my God...thanks...you know I've been feeling so shit about myself recently, that's made me feel so much better. You are so nice. Maggie is so lucky to have you." The most he gets is a, "Cool", or "Thanks" and fairly neutral expression. I've totally stopped acknowledging some things he's definitely doing for my benefit too (actually the more I'm writing the more I'm getting pissed off at him and his needy little boy ways). I just give off strong disinterested vibes even though under a different set of circumstances I would have been interested. He's not single. End of. You are married, OP. This could wreck your marriage if you feed it. End of.
Good Luck. He's honestly not all that. Step back. Get a bit of perspective. Tell him to rein it in if you have to. Focus on you. See this as an opportunity to acknowledge your needs and go about getting them met in a better way.
Oh. And stay sober around him.